淘先锋技术网

首页 1 2 3 4 5 6 7

生成student类的两个对象?

public class Student {

/**

* @param sNo

* @param sName

* @param sSex

* @param sAge

* @param sGrade

*/

public Student(String sNo, String sName, String sSex, int sAge,

String sGrade) {

super();

this.sNo = sNo;

this.sName = sName;

this.sSex = sSex;

this.sAge = sAge;

this.sGrade = sGrade;

}

/**

* @return the sAge

*/

public int getsAge() {

return sAge;

}

/**

* @param sAge the sAge to set

*/

public void setsAge(int sAge) {

this.sAge = sAge;

}

/**

* @return the sName

*/

public String getsName() {

return sName;

}

/**

* @return the sGrade

*/

public String getsGrade() {

return sGrade;

}

private String sNo;

private String sName;

private String sSex;

private int sAge;

private String sGrade;

}

public class TestStudent {

public static void main(String[] args) {

Student student = new Student("001", "Tom", "male", 28, "grade 6");

System.out.println("Name = " + student.getsName() + ";Age = "

+ student.getsAge() + ";Grade = " + student.getsGrade());

student.getsAge();

student.getsGrade();

student.getsName();

student.setsAge(12);

System.out.println("Age after modify = " + student.getsAge());

}

}