package std.info;
public class Student {
public String number,name,gender;
private int age;//声明成员变量学号/姓名/性别/年龄
//修改学号,姓名,性别,年龄的方法
public void setNumber(String number){
this.number=number;
}
public void setName(String name){
this.name=name;
}
public void setGender(String gender){
this.gender=gender;
}
public void setAge(int age){
this.age=age;
}
//显示学号,姓名,性别,年龄的方法
public void displayNumber(){
System.out.println(this.number);}
public void displayName(){
System.out.println(this.name);}
public void displayGender(){
System.out.println(this.gender);
}
public void displayAge(){
System.out.println(this.age);
}
}
class StudentDemo{
public static void main(String[]args){
std.info.Student s=new Student();//创建一个学生对象
s.setNumber("2016");
//或者s.number="2016";
s.setName("w");
s.setGender("female");
s.setAge(18);
s.displayNumber();
//System.out.println(s.number);
s.displayName();
s.displayGender();
s.displayAge();
}
}