Fill to a sub range of elements in a short type array in Java
Description
The following code shows how to fill to a sub range of elements in a short type array.
Example
// w ww . j a va2s .c om
import java.util.Arrays;
public class Main {
public static void main(String[] argv) throws Exception {
int startIndex = 0;
int endIndex = 4;
short[] shortArr = new short[10];
short shortFillValue = 1;
System.out.println(Arrays.toString(shortArr));
Arrays.fill(shortArr, startIndex, endIndex, shortFillValue);
System.out.println(Arrays.toString(shortArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »