发布网友 发布时间:2022-04-24 17:52
共1个回答
热心网友 时间:2023-10-28 12:54
public class Test {
public static void main(String[] args) {
Student s = new Student();//这边可以给有参构造赋值
s.show();
}
}
class Student{
private String yuwen;
private String shuxue;
private String yingyu;
public String getYuwen() {
return yuwen;
}
public void setYuwen(String yuwen) {
this.yuwen = yuwen;
}
public String getShuxue() {
return shuxue;
}
public void setShuxue(String shuxue) {
this.shuxue = shuxue;
}
public String getYingyu() {
return yingyu;
}
public void setYingyu(String yingyu) {
this.yingyu = yingyu;
}
public Student(){}
public Student(String yuwen,String shuxue,String yingyu){
this.yuwen=yuwen;
this.shuxue=shuxue;
this.yingyu=yingyu;
}
public void show(){
System.out.println("这是学生类!!!!");
}
}
这就是一个类里面有两个类,这叫类部类!希望能帮到你!