标题: 无法将类 jiChu中的构造器 jiChu应用到给定类型&&求大神看下怎么回事?? [打印本页] 作者: 房奴的影子 时间: 2016-7-26 16:15 标题: 无法将类 jiChu中的构造器 jiChu应用到给定类型&&求大神看下怎么回事?? class test2 {
public static void main(String[] args) {
jiChu j=new jiChu("佳佳",23);
j.study();
abstract 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 String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public abstract void study();
}
class jiChu extends student {
public jiChu(){}
public void jiChu(String name,int age){
super (name, age);
}
public void study(){
System.out.println("我的姓名是:"+getName()+",我的年龄是:"+getAge()+",学习的是Java基础");
}
}