public class Rectangle
{
int width;
int height; //构建器
public Rectangle(int w,int h)
{
setRectangle(w, h);
}
/**
 * 
 */
//////////////////////////////////////////////////////////////////////////
以下这段是eclipse加上去、这一段我不明白。
public Rectangle() {

// TODO Auto-generated constructor stub
}
////////////////////////////////////////////////////////////////////////////
//以下为方法的声明,该方法设置矩形的长和宽
void setRectangle(int w, int h)
{
width=w;
height=h;
}
public static void main(String args[])
{
int x=5,y=10,z;
Rectangle a = new Rectangle();
a.setRectangle(x,y);
System.out.println("Width=" + x + " Height=" + 10);
System.out.println("a.Width=" + a.width + " a.Height=" + a.height);
}

}完成的代码:但我有以下不明白是不是:Rectangle a = new Rectangle();
中Rectangle()因为我没有写参数的原因吗?只有加了上面哪一段代码后才可以不报错。