学生类:
public class Student{
private String name;
private int age;
private double score;
public dd(String name, int age, double score) {
super();
this.name = name;
this.age = age;
this.score = score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public void printInfo()
{
System.out.println("name:"+name);
System.out.println("age:"+age);
System.out.println("score:"+score);
}
} main() 方法:public class TestStudent{
public static void main(String[] args) {
Student stu=new Student("李四",20,89);
stu.printInfo();
}} 友情提示:考试的题目还是应该自己做,尽管就是做错了,那对自己还是很有帮助的