Fill to a sub range of elements in a double type array in Java
Description
The following code shows how to fill to a sub range of elements in a double type array.
Example
/* w w w .ja v a 2 s.co m*/
import java.util.Arrays;
public class Main {
public static void main(String[] argv) throws Exception {
int startIndex = 0;
int endIndex = 4;
double[] doubleArr = new double[10];
double doubleFillValue = 1;
System.out.println(Arrays.toString(doubleArr));
Arrays.fill(doubleArr, startIndex, endIndex, doubleFillValue);
System.out.println(Arrays.toString(doubleArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »