a中元素的默认值为
boolean[]false。您不需要做任何事情。
之所以需要这样做
Boolean[]是因为默认值为
null。
要初始化为true,使用过载的
Arrays.fill一个接受
boolean[]。
boolean[] seats = new boolean[10];Arrays.fill(seats, true);
看到它在线上工作:ideone

a中元素的默认值为
boolean[]false。您不需要做任何事情。
之所以需要这样做
Boolean[]是因为默认值为
null。
要初始化为true,使用过载的
Arrays.fill一个接受
boolean[]。
boolean[] seats = new boolean[10];Arrays.fill(seats, true);
看到它在线上工作:ideone