boolean array default value java code example
Example 1: default value boolean array java
boolean[] boolArray = new boolean[5];
Example 2: how to initalize the array as to false
import java.util.Arrays;
public class BooleanArrayTest {
public static void main(String[] args) {
Boolean[] boolArray = new Boolean[5];
for(int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
Arrays.fill(boolArray, Boolean.FALSE);
for(int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
Arrays.fill(boolArray, Boolean.TRUE);
for (int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
}
}