You are given a 2-D array with dimensions X code example
Example 1: 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]; // initialize a boolean array
for(int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
Arrays.fill(boolArray, Boolean.FALSE);
// all the values will be false
for(int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
Arrays.fill(boolArray, Boolean.TRUE);
// all the values will be true
for (int i = 0; i < boolArray.length; i++) {
System.out.println(boolArray[i]);
}
}
}
Example 2: You are given a 2-D array with dimensions X
2 2
1 2
3 4
24