數(shù)據(jù)加載中……
          ArrayListTest.java
          /**
          *i測(cè)試數(shù)組列表的使用
          */
          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+=",專業(yè)="+strSpeciality;
          if(!strAddress.equals(""))
          information+=",籍貫="+strAddress;
          return information;
          }
          }

          posted on 2008-10-22 23:33 郭興華 閱讀(142) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 高雄县| 荣成市| 蓬安县| 修水县| 闽侯县| 临夏市| 高安市| 保亭| 罗源县| 成武县| 岐山县| 阳曲县| 九江市| 连州市| 普宁市| 耒阳市| 赣州市| 湘乡市| 涟水县| 拜泉县| 翼城县| 嘉定区| 阜康市| 大厂| 云浮市| 绥中县| 英德市| 安化县| 本溪| 九寨沟县| 正阳县| 鄂托克前旗| 天祝| 建宁县| 东兰县| 古浪县| 常山县| 临清市| 陇南市| 邢台县| 柳河县|