java133-泛型
作者:互联网
public class Employee {
private String name;
private String ags;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setAgs(String ags) {
this.ags = ags;
}
public String getAgs() {
return ags;
}
}
测试类
import java.util.ArrayList;
import java.util.List;
//泛型
public class test72 {
public static void main(String[] args){
List<Employee> empList=new ArrayList<Employee>();
Employee emp1=new Employee();
emp1.setName("歌谣");
Employee emp2=new Employee();
emp2.setName("小白");
Employee emp3=new Employee();
emp3.setName("小红");
empList.add(emp1);
empList.add(emp2);
empList.add(emp3);
for(Employee emp:empList){
System.out.println(emp.getName());
}
}
}
结果
标签:String,empList,Employee,java133,泛型,ags,public,name 来源: https://www.cnblogs.com/yao-655442/p/16411677.html