怎样用数组的方式,来存储下面这个表格的数据?
示例代码如下:
import java.util.Arrays;
public class Test001 {
public static void main(String[] args) {
/*object类对象是类层次结构的根。每个类都有Object作为超类。所有对象,包括数组,都实现这个类的方法。*/
/*以下是先定义一个一维数组,这里object是引用类型,作用相当于前面学过的int.*/
Object[ ]a1 = {1001,"高 淇",18,"讲师","02-14"};
Object[ ]a2 = {1002,"高小七",19,"助教","10-10"};
Object[ ]a3 = {1003,"高小八",20,"班主任","05-05"};
/*再义一个二维数组,把上面的一维数组放进去,这就跟上一节学的二组数组的第三种定义和初始化方式是一样的了*/
Object[][] employees = new Object[3][];
employees[0] = a1;
employees[1] = a2;
employees[2] = a3;
System.out.println(Arrays.toString(employees[0]));
System.out.println(Arrays.toString(employees[1]));
System.out.println(Arrays.toString(employees[2]));
}
}
运行结果: