首页 新闻 搜索 专区 学院

结果是多少?

0
悬赏园豆:10 [已关闭问题] 关闭于 2022-12-15 15:02

import java.util.Vector;
public class TestVector{
public static void main(Stringlargs) {
Vector<Student> vector = newVector<Student>();
Student stu1 = new Student("Zhang", "01", 75);
Student stu2 = new Student("Li", "02", 86);
vector.add(stu1);
vector.add(stu2);
for(Student stu: vector){
System.out.println(stu.toString());
}
}
}
class Student{
private String name;
private String id;
private int grade;
public Student(String name, String id, int grade){
this.name = name;
this.id =id;
this.grade =grade;
}
public String toString(){
return "" + name + "'," + id +"," + grade
}
}

程序运行的结果:
(1)_________
(2)__________

peir的主页 peir | 初学一级 | 园豆:105
提问于:2022-12-05 12:57
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册