当前位置: 代码迷 >> Windows2000 >> Unresolved compilation problems: Cannot instantiate the type Rectangle解决方案
  详细解决方案

Unresolved compilation problems: Cannot instantiate the type Rectangle解决方案

热度:3838   发布时间:2013-02-26 00:00:00.0
Unresolved compilation problems: Cannot instantiate the type Rectangle
package exit5;

public class testabstract {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
  Shape shape1,shape2;
  shape1=new Rectangle(10.0,20.0);
  shape1.showarea();
shape2=new Circle(10.0);
  shape2.showarea();
  shape2.resize(0.2);
  shape2.showarea();
}

}package exit5;

public abstract class Rectangle extends Shape {
  double w,h;
  public Rectangle(double h0 ,double w0) {
// TODO Auto-generated constructor stub
h=h0;w=w0;
}
  double getarea(){
return h*w;
  }
  void resize(double factor){
w*=factor;h*=factor;
  }
}


------解决方案--------------------------------------------------------
abstract class couldn't be instance.
  相关解决方案