class MyBox 
{private int x,y,with,height; 
   MyBox() 
{x=0;y=0;width=0;height=0; 

   MyBox(int x, int y,int width,int height) 
{this,x=x;this,y=y;this,width=width;this,height=height;

public void set(int x, int y,int width,int height) 
{this,x=x;this,y=y;this,width=width;this,height=height; 

解决方案 »

  1.   

    MyBox(int x, int y,int width,int height) {
     this.x=x;
     this.y=y;
     this.width=width;
     this.height=height;
    }
      

  2.   

    “如何将MyBox类中的Set方法造成类的构造方法 
    请赐教”
    不知道你说的什么意思?!!!!!
    看看下面是不是你想要的?!class MyBox {
       private int x,y,with,height;    MyBox(){
         x=0;
         y=0;
         width=0;
         height=0; 
         set(x,y,width,heigh);
       }    public void set(int x,int y,int width,int heigh{
         this.x=x;
         this.y=y;
         this.width=width;
         this.height=height; 
       } 
      

  3.   

    是不是下面所示:
    class MyBox {
       private int x,y,with,height;    private MyBox(int x,int y,int width,int heigh){ //不能用此构造对象
         x=0;
         y=0;
         width=0;
         height=0; 
         
       }    public static void set(int x,int y,int width,int heigh){//类方法只能构造一个对象
       MyBox  myBox=new MyBox(x,y,width,heigh);
       }