Arrays in Java store one of two things: either primitive values (int, char, ...) or references (a.k.a pointers).java
Arrays 在Java 中存儲兩者之一: 原始數據類型(int,char,...)或者是引用(a.k.a 指針) When an object is creating by using "new", memory is allocated on the heap and a reference is returned. This is also true for arrays, since arrays are objects.數組
當一個對象經過使用"new"來建立,會在堆內存中分配而且返回一個引用。這也一樣適用數組,由於數組是對象。指針
int arr[] = new int[3];
The int[] arr is just the reference to the array of 3 integer. If you create an array with 10 integer, it is the same - an array is allocated and a reference is returned.code
int數組arr 僅僅是三個Integer對象的數組的引用。若是你建立一個10個integer的數組,它是和一個數組相同分配在內存中,而且返回一個引用。對象
How about 2-dimensional array? Actually, we can only have one dimensional arrays in Java. 2D arrays are basically just one dimensional arrays of one dimensional arrays.圖片
二維數組是如何實現的?廣泛的上,在java中,咱們只有一維數組。二維數組基本上僅公是一維數組中的一維數組。內存
int[ ][ ] arr = new int[3][ ]; arr[0] = new int[3]; arr[1] = new int[5]; arr[2] = new int[4];
Multi-dimensional arrays use the name rules.it
多維數組也是相同的規則。io