static String[][][] School= new String[1000][20][5];
考慮圖有3維。
所以當你插入School[0][0][0]="A1"
這意味着你已經在0,0,0位置輸入了元素。
從0,0,0這將移動到位置1000,20,5。
您可以像這樣插入但是您擁有如此多的元素。
School[0][0][0]="A1"
School[0][0][1]="A2"
School[0][0][2]="A3"
.....
School[0][1][0]="B1"
School[0][1][1]="B2"
School[0][1][2]="B3"
......
在三維數組元素看起來像
int[3][4][2] array3D
// means Three (4x2) 2 Dimensional Arrays
int[4][2]
//means Four 1 dimensional arrays.
現在如何在3D陣列添加元素?
在開始你可以直接使用
int[][][] threeDArray =
{ { {1, 2, 3}, { 4, 5, 6}, { 7, 8, 9} },
{ {10, 11, 12}, {13, 14, 15}, {16, 17, 18} },
{ {19, 20, 21}, {22, 23, 24}, {25, 26, 27} } };
這是你的情況非常枯燥的事情,只要你想在每一個位置插入細節。 正如您有1000
記錄。
你的陣列將有這樣
![enter image description here](https://i.stack.imgur.com/y7NVf.jpg)
注意元素:它不推薦使用3D陣列用於此目的。
建議:聲明一個類有三個Strings
與此三個參數創建構造函數,並把getter和setter方法來獲得,並通過Objects
選中此項 - [Java程序添加兩個三維(3D)數組。](http://www.msccomputerscience.com/2013/02/java-program -to-附加兩three.html) – ARJUN