class ProductAttribute{
double width,length,height;
ProductAttribute(double x,double y,double z){
width = x;
length = y;
height = z ;
}
double volumeCaculate(){
return width*length*height;
}
public void showSize(){
System.out.println("width length height are "+width+","+length+","+height);
}
} class TVAttribute extends ProductAttribute{
double price ;
TVAttribute (double x ,double y,double z ,double p){
super (x,y,z);
price = p;
}
public void showPrice(){
System.out.println("the price is "+price);
}
} class ColorTVAttribute extends TVAttribute{
double price ;
String TradeMark;
ColorTVAttribute (double x ,double y,double z,double p,String ){
super(x,y,z,p);
TradeMark = ;
}
public void showTradeMark(){
System.out.println("the trade  is "+TradeMark);
}
} class MultiLevelsInheritance{
public static void main(String args[]){
double volume;
ColorTVAttribute colorTV = new ColorTVAttribute(50,60,70,80,"sony");
volume = colorTV.volumeCaculate();
System.out.println("volume is of colorTV "+volume);
colorTV.showSize();
colorTV.showPrice();
colorTV.showTradeMark();
}
}为什么出现::
D:\java\digui>java MultiLevelsInheritance
volume is of colorTV 210000.0
Exception in thread "main" java.lang.NoSuchMethodError: ColorTVAttribute.showSiz
e()V
        at MultiLevelsInheritance.main(MultiLevelsInheritance.java:47)为什么会找不到!

解决方案 »

  1.   

    我运行了一下楼主的代码,没有发现问题。
    后台的输出结果:
    volume is of colorTV 210000.0
    width length height are 50.0,60.0,70.0
    the price is 80.0
    the trade  is sony
      

  2.   

    Exception in thread "main" java.lang.NoSuchMethodError: ColorTVAttribute.showSiz
    e()V
            at MultiLevelsInheritance.main(MultiLevelsInheritance.java:47)给出的错误提示是:
    没有这个方法 ColorTVAttribute.showSize()V
    而造成的错误,错误出现在第47行处
      

  3.   

    搞懂了,是我classpath设置的问题,谢谢大家