数组声明,分配, 赋值
int y[] = new int[3]; y[0] = 1; y[1] = 2; y[2] = 3; int[] x = new int[] {1,2,3}; int[] x = {1,2,3};
二维数组
String[][] x = {{"00","01"},{"10","11"}}; String[][] y = new String[2][2]; y[0][0] = "00"; y[0][1] = "01"; y[1][0] = "10"; y[1][1] = "11";
Arraylist
java.util.ArrayList a = new java.util.ArrayList(); a.add("Hi"); // add an element a.set(0, "Hello"); // change first element a.remove(0); // remove first element a.add("Hello World"); String s = (String)a.get(0); // Hello World
Java 语法 索引 ----- 数组(Arrays),布布扣,bubuko.com
时间: 2024-12-19 17:29:49