[Java] 纯文本查看 复制代码 class A_Student{
public static void main(String[] args) {
Student s1 = new Student();
s1.setName("张三");
s1.setAge(24);
System.out.println("我的名字是:" + s1.getName() +",我的年龄是:"+ s1.getAge());
}
}
class Student {
private String name;
private int age;
public Student(){}
public Student(String name,int age) {
this.name = name;
this.age = age;
}
public void setName(String name){
this.name = name;
}
public void getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public void getAge() {
return age;
}
public void show(){
System.out.println("我的名字是:" + name +",我的年龄是:" + age);
}
} |