what is the result of foo?

int index = 1;
String[] test = new String[3];
String foot = test[index];
System.out.println(foot);
A. ""          
B. null        
C. throw a Exception  
D. not compile

 参考答案

B; 数组初始化时有默认值,String类型数组默认值为null,所以会打印null


results matching ""

    No results matching ""