/**1:标准学生类定义及使用。*/
class Student
{
private String name;
private int age;
Student(String name,int age){
this.name=name;
this.age=age;
}
public void study(){
System.out.println(age+"的"+name+"努力学习");
}
public void setName(String name){
this.name=name;
}
public void setAge(int age){
this.age=age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
}
class StudentTest
{
public static void main(String[] args)
{
Student s=new Student("小明",13);
s.study();
}
}
|
|