package day05;
//需求:定义类并测试;
public class Demo06 {
public static void main(String[] args) {
Student stu1=new Student("张三",88);
stu1.introduce();
Student stu2=new Student();
stu2.setName("李四”);
stu2.setScore(96);
stu2
.introduce();
}
}
class Student{
String name;
int score;
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public int getScore(){
return score;
}
public void setScore(int score){
this.score=score;
}
Student(){
System.out.println("无参的构造方法被执行了!");
}
Student(String name,int score){
this.name=name;
this.score=score;
}
public void introduce(){
System.out.println("大家好,我叫"+name+"我考了"+score+"分!");
}
}
慕容慕
深白
erutdioup8556
相关分类