-
Java Basic (7) - Multidimensional ArraysJava 2021. 5. 20. 01:18
Arrays
- In java, array can have any type of data, including another array
- 2D array is not actually represented graphically in the memory
- Array[row][col], but technically there are no "rows" and "columns"
- Just make sure you remember which dimension is which
- There are no limits to the number of dimensions for arrays
- The "rows" don't need to be the same size
- int[][] a = {{1,2}, {1,2,3,4,5,6}, {1}}
- You can leave the smaller arrays unallocated (the last dimensions only, you must give the first sizes>0 then you can leave the rest blank)
- int[][][][] a = new int[3][5][][] //works
- You can create arrays containing smaller arrays of assorted sizes
- int[][] a = new int[3][]
- a[0] = new int[4]
- a[1] = new int[2]
- a[2] = new int[3]
'Java' 카테고리의 다른 글
Java Basic (10) - Object hierarchies(1) (0) 2021.05.27 Java Basic (8) - Exceptions (0) 2021.05.22 Java Basic (6) - Objects containing objects, Passing an object to a method (0) 2021.05.20 Java Basic (5) - Object, clone(), copy (0) 2021.05.19 Java Basic (4) - public, private, encapsulation, accessor/mutator, get/set, static (0) 2021.05.16