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