java技术博客

jsp博客
<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

统计

  • 随笔 - 84
  • 文章 - 1
  • 评论 - 2
  • 引用 - 0

常用链接

留言簿(3)

随笔分类

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

ArrayListTest.java
/**
*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;
}
}

posted on 2008-10-22 23:33 郭兴华 阅读(137) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: