数组(容器):
格式: 数据类型 数组名[ ] = new 数据类型 [ 数组的长度 ]
例子:int arr1[] = new int[5] //静态
int arr1[] ={2,4,6,4,8,6,5,1,8}; //动态
*为了存储同种数据类型的多个值。
数组概念:
* 数组是存储同一种数据类型多个元素的集合。
* 数组既可以存储基本数据类型,也可以存储引用数据类型。
Java中的内存分配:
栈(先进后出)
* 存储局部变量。
堆:
*存储New出来的数组或对象。
方法区:
*********
本地方法区:
*********
寄存器 :
*给CPU使用
二维数组
格式:
* int arr[ ] [ ] =new int [ ] [ ];
基本数据类型的值传递,不改变原值,因为方法调用后就会弹栈,局部变量随之消失。
引用数据类型的值传递,改变原值,因为即使方法弹栈,但是堆内存储数组对象还在,可以通过地址继续访问。