数组
数组定义:数据类型[]数组名;
动态数组:数据类型[]数组名=new 数据类型[数组长度];
访问数组元素格式:数组名[索引];
静态数组:数据类型[]数据名=new 数据类型[]{元素1,元素2,......};
数据类型[]数组名={元素1,元素2,.....};
内存
方法区里有字节码文件,而其中方法栈中有对象和new和main方法,数组名在方法栈中链接堆内存中的数组地址,数组都储存在堆内存中。
数组遍历:public class gj {
public static void main(String[] args) {
int[] arr = {11, 22, 33, 44, 55};
for(int x=0; x
System.out.println(arr[x]);
}
}
}
索引越界异常出现:ArrayIndexOutOfBoundsException。
空指针异常出现: NullPointerException。



