importjava.util.ArrayList;publicclasstest{publicstaticvoidmain(String[]args){ArrayListarrayList=newArrayList<>();arrayList.add(newstudent("teacher","male",18));a...
import java.util.ArrayList;
public class test {
public static void main(String[] args) {
ArrayList arrayList = new ArrayList<>();
arrayList.add(new student("teacher", "male", 18));
arrayList.add(new student("teacher", "famle", 45));
arrayList.add(new student("student", "female", 56));
arrayList.add(new student("teacher", "male", 21));
arrayList.add(new student("teacher", "female", 22));
arrayList.add(new student("student", "male", 34));
arrayList.add(new student("student", "male", 23));
arrayList.add(new student("student", "female", 32));
for(student s:arrayList) {
System.out.println(s);
}
}
}
class student{
String idString;
String genderString;
int age;
public student(String idString, String genderString, int age) {
super();
this.idString = idString;
this.genderString = genderString;
this.age = age;
}
}
展开