import java.util.ArrayList;
public class Test3 {
public static void main(String[] args) {
ArrayList<Teacher> array = new ArrayList<>();
Teacher t1 = new Teacher("赵老师","javase");
Teacher t2 = new Teacher("钱老师","jabaee");
Teacher t3 = new Teacher("孙老师","php");
Teacher t4 = new Teacher("李老师","python");
array.add(t1);
array.add(t2);
array.add(t3);
array.add(t4);
for(int i = 0;i< array.size();i++){
Teacher t = array.get(i);
System.out.println("姓名:"+t.getName()+",专业:"+t.getMajor());
}
}
}
|
|