代码:
class Pen {
String color;
int length;
public Pen(){
}
Pen(String color) {
this.color =color;
}
Pen(int length){
this.length=length;
}
Pen(String color,int length){
this.color =color;
this.length=length;
}
void display(){
System.out.print("Color is "+color);
System.out.print("length is "+length);
}
}
class myPen extends Pen {
int weigth;
public myPen(){
}
myPen(String color,int weigth){
super(color);
this.weigth=weigth;
}
myPen(int length,int weight){
super(length);
this.weigth =weigth;
}
myPen(String color,int length,int weight){
super(color,length);
this.weigth =weigth;
}
void dislay(){
super.display();
System.out.print("weight is"+weigth);
}
}
public class superExam{
public static void main(String args[]){
myPen p=new myPen("blue 13.56");
p.dislay();
}
}
报错为:
Exception in thread "main" java.lang.Error: 无法解析的编译问题:
构造函数 myPen(String)未定义 at superExam.main(superExam.java:44)