- public static void main(String[] args) {
- Student[] s = new Student[5];
- s[0] = new Student("张三", 23);
- s[1] = new Student("李四", 24);
- s[2] = new Student("王五", 25);
- s[3] = new Student("赵六", 26);
- s[4] = new Student("张三", 27);
- System.out.println(s);
- System.out.println(s[1]);
-
- }
复制代码 运行结果是[Lcn.itcast.bean.Student;@100363
Student [name=李四, age=24]
怎样可以做到像集合那样,当打印数组名时直接将所有元素以对象的形式打印出来。该区修改哪个toString方法
|
|