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