java技術博客

          jsp博客
          數據加載中……
          StudentTest3.java
          public class StudentTest3{
          public static void main(String[] args){
          Student tom=new Student("Tom","20020410");
          tom.setStudentSex("man");
          tom.setSutdentAddress("America");
          System.out.println(tom.toString());
          }
          }
          class Student{
          private String strName="";
          private String strNumber="";
          private String sexSex="";
          private String strBirthday="";
          private String strSpeciality="";
          private String strAddress="";
          public static void main(String[] args){
          Student aStudent=new Student("沙和尚","19990000");
          aStudent.setStudentAddress("通天河");
          System.out.println(aStudent.toString());
          }
          public Student (String name,String number){
          strName=name;
          strNumber=number;
          }
          public String getStudentName(){
          return strName;
          }
          public void setStudentSex(String sex){
          strSex=sex;
          }
          public  String getStudentSex(){
          return strSex;
          }
          public String getStudentBirthday(){
          return strBirthday;
          }
          public void setStudentSpciality(String speciality){
          strSpeciality=speciality;
          }
          public String getStudentAddress(){
          return strAddress;
          }
          public void setStudentAddress(String address) {
          strAddress=address;
          }

          public String toString(){
          String information="學生姓名="+strName+",學號="+strNumber;
          if(!strSex.equals("")){
          information+=",性別="+strSex;
          if(!strBirthday.equals(""))
          information+=", 出生年月="+strBirthday;
          if(!strSpeciality.equals(""))
          information+=",專業="+strSpeciality;
          if(!strAddress.equals(""))
          information+=",籍貫="+strAddress;
          return information;
          }
          }
             }

          posted on 2008-10-21 20:56 郭興華 閱讀(115) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 垦利县| 南昌市| 察哈| 常宁市| 彭州市| 长乐市| 崇信县| 南汇区| 衡阳县| 库车县| 峨眉山市| 孝义市| 贵南县| 克拉玛依市| 广西| 乳源| 承德市| 海淀区| 青河县| 湟中县| 监利县| 祁阳县| 凌源市| 搜索| 大埔县| 太原市| 延吉市| 高碑店市| 堆龙德庆县| 沐川县| 铜鼓县| 巴楚县| 桃源县| 建平县| 桐柏县| 昌吉市| 隆林| 务川| 沧州市| 西乌珠穆沁旗| 青海省|