class Student{
static private String name;
static private int age;
static private String sex;
public Student(){
}
public void set(String name,int age,String sex){
this.name=name;
this.age=age;
this.sex=sex;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public String getSex(){
return sex;
}
public static void show(){
System.out.println("学生姓名"+name);
System.out.println("学生年龄"+age+"岁");
System.out.println("学生姓别"+sex);
}
}
class StudentTest
{
public static void main(String[] args)
{
Student student= new Student();
student.set("小明",14,"男");
student.show();
}
}
不知道对不对
|
|