java中系统数组初始化

2025-01-04 18:09:35
推荐回答(4个)
回答1:

成员变量,你不设值它也会初始化为null,但在方法中的局部变量就必须要初始化了

Boolean array[] = {true,true};

Boolean array[] = new Boolean[2];
array[0] = true;
array[1] = true;

回答2:

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);
}

回答3:

Boolean[] i = new Boolean[2];
Boolean[] j = {false,true};

都可以

回答4:

Boolean array[] = {true,true};

Boolean array[] = new Boolean[2];
array[0] = true;
array[1] = true;