Fill to a sub range of elements in a boolean type array in Java
Description
The following code shows how to fill to a sub range of elements in a boolean type array.
Example
/*w w w . ja va2 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;
boolean[] booleanArr = new boolean[10];
boolean booleanFillValue = true;
System.out.println(Arrays.toString(booleanArr));
Arrays.fill(booleanArr, startIndex, endIndex, booleanFillValue);
System.out.println(Arrays.toString(booleanArr));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »