你好,
我是 Java 新手,想弄清楚如何将这些数据推送到数组中(6 行,3 列)?
x1 John 6
x2 Smith 9
x3 Alex 7
y1 Peter 8
y2 Frank 9
y3 Andy 4
之后,我将从最后一列中取出数字进行数学计算。
这是我的代码...
public class Testing {
public static void main(String[] args) {
Employee eh = new Employee_hour();
Employee_hour [] eh_list = new Employee_hour[6];
eh_list[0] = new Employee_hour("x1", "John", 6);
eh_list[1] = new Employee_hour("x2", "Smith", 9);
eh_list[2] = new Employee_hour("x3", "Alex", 7);
eh_list[3] = new Employee_hour("y1", "Peter", 8);
eh_list[4] = new Employee_hour("y2", "Frank", 9);
eh_list[5] = new Employee_hour("y3", "Andy", 4);
print(eh_list);
}
private static void print(Employee_hour[] mass){
for (int i = 0; i < mass.length; i++) {
System.out.print(mass[i] + " ");
}
System.out.println();
}
}
但我得到这个作为输出......
testing.Employee_hour@1a752144 testing.Employee_hour@7fdb04ed testing.Employee_hour@420a52f testing.Employee_hour@7b3cb2c6 testing.Employee_hour@4dfd245f testing.Employee_hour@265f00f9
如何从最后一列获取数字?