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 郭興華 閱讀(114) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 芦山县| 泌阳县| 阿克陶县| 铜梁县| 拉萨市| 大邑县| 额济纳旗| 新和县| 鄢陵县| 大荔县| 吉木萨尔县| 汉阴县| 伊金霍洛旗| 越西县| 永康市| 安义县| 临朐县| 绍兴县| 丰城市| 罗源县| 永吉县| 新巴尔虎左旗| 岑溪市| 遂平县| 乡宁县| 旌德县| 沙河市| 德令哈市| 华池县| 马龙县| 谷城县| 上栗县| 景东| 北海市| 博野县| 福安市| 奎屯市| 鲁山县| 平武县| 六盘水市| 宣化县|