Java支持一维和多维数组。请参阅以下示例:
示例public class Tester {
public static void main(String[] args) {
double[] myList = {1.9, 2.9, 3.4, 3.5};
//打印所有数组元素
for (double element: myList) {
System.out.print(element + " ");
}
System.out.println();
int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} };
for(int i = 0 ; i
//行
for(int j = 0 ; j
System.out.print(multidimensionalArray[i][j] + " ");
}
System.out.println();
}
}
}
输出结果1.9 2.9 3.4 3.5
1 2
2 3
3 4