填空题
本题定义了一个长度为10的boolean型数组,并给数组元素赋值,要求如果数组元素下标为奇数,则数组元素值为false,否则为true。
public class java1
public static void main(String[] args)
boolean b[]=______;
for(int i=0; i<10; i++)
if(______)
b[i]=false;
else
______;
for(int i=0; i<10; i++)
System. out. print("b["+i+"]="+b[i]+",");
【参考答案】
第1处:new boolean[10]
第2处:i%2!=0
第3处:b[i]=true