成员变量,你不设值它也会初始化为null,但在方法中的局部变量就必须要初始化了
Boolean array[] = {true,true};
或
Boolean array[] = new Boolean[2];
array[0] = true;
array[1] = true;
B//定义boolean数字
Boolean[] bools = new Boolean[2];
//初始化数字
Boolean[] bools2 = { true, false };
for (int i = 0; i < bools.length; i++) {
System.out.println(bools);
}
for (int i = 0; i < bools2.length; i++) {
System.out.println(bools2);
}
Boolean[] i = new Boolean[2];
Boolean[] j = {false,true};
都可以
Boolean array[] = {true,true};
或
Boolean array[] = new Boolean[2];
array[0] = true;
array[1] = true;