java in memory division, the use of an array

/ * Process run are stack (Stack) is stored in the variable, the method in a certain stack
* local variables: parameters of the method, or a method of internal variables {}
* Scope: Ultra but at a scope, immediately disappear from the stack
* 2 heap (heap) all new things out of the heap
have default values * heap inside the data
* If it is an integer type defaults to 0 if it is float default 0.0 If the default character is u / 0000 If the default is false boolean If defaults to null reference type
has an address value * heap stuff inside
* 3 area method (method area): class related information includes information storing method
4. native method stacks * (Native Method Stack) and the related operating system

* 5. Cpu registers and related

*/

public class for1 {
public static void main(String[] args) {
int[] array=new int[5];
System.out.println(array);
System.out.println(array[0]);
System.out.println(array[1]);
System.out.println(array[2]);
System.out.println(array[3]);
System.out.println(array[4]);
System.out.println(array[5]);//ArrayIndexOutOfBoundsException索引越界异常
int num=array.length;//获取数组长度
//数组遍历输出
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);

}
int[] arrayA;
arrayA=null;
System.out.println (arrayA [0]); // null pointer exception a NullPointerException

}
}

Guess you like

Origin www.cnblogs.com/xzwx668/p/11992700.html