/**
*i测试数组列表的使用
*/
import java.util.ArrayList;
public class ArrayList{
public static void main(String[] args){
ArrayList list=new ArrayList();
list.add(new Student("Tom","20020410"));
list.add(new Student("Jack","20020411"));
list.add(new Student("Rose","20020412"));
for(int i =0;i<list.size();i++)
{
System.out.println((Student)list.get(i));
}}}
class Student {
private String strName="";
private String strNumber="";
private String strSex="";
private String strBirthday="";
private String strAddress="";
public Student(String name,String number){
strName=name;
strNumber=number;
}
public String getStudentName(){
return strName;
}
public String getStudentNumber() {
return strNumber;
}
public String setStudentSex(String sex)
{
strSex=sex;
}
public String getStudentSex(){
return strSex;
}
public String getStudentBirthday(){
return strBirthday;
}
public void setStudentBirthday(String birthday){
strBirthday=birthday;
}
public String getStudentSpeciality(){
return strSpeciality;}
public void setStudentSpececiality(String speciality){
strSpeciality=speciality;
}
public void setStudentAddress(String address){
strAddress=address;
}
public String toString(){
String information="student name="+strName+",student number="+strNumber;
if(!strSex.equals(""))
information+=",sex="+strSex;
if(!strBirthday.equals(""))
information+=",birthday="+strBirthday;
if(!strSpeciality.equals(""))
information+=",专业="+strSpeciality;
if(!strAddress.equals(""))
information+=",籍贯="+strAddress;
return information;
}
}