数组初始化规则:
测试类:
public class A {
public static void main(String[] args) {
char []ch=new char[3];
int []in=new int[2];
String []str=new String[2];
Integer []In=new Integer[2];
System.out.println("ch[0]:"+ch[0]);
System.out.println("in[0]:"+in[0]);
System.out.println("str[0]:"+str[0]);
System.out.println("In[0]:"+In[0]);
}
}
运行结果:

char类型数组初始化为空格
int 类型初始化为0
String类型初始化为null
Integer类型初始化为null
博客介绍了数组初始化规则,通过测试类展示运行结果。具体说明了不同类型数组的初始值,如char类型数组初始化为空格,int类型初始化为0,String和Integer类型初始化为null。
304

被折叠的 条评论
为什么被折叠?



