java 编写的程序 一运行就显示找不到或无法加载主类Rectangle

java 编写的程序 一运行就显示找不到或无法加载主类Rectangle
public class Rectangle implements Area //矩形类 计算面积接口
{
protect double length; //长度
protect double width; //宽度
public Rectangle(double length,double width) //构造方法
{
this.length=length;
this.width=width;
}
public Rectangle(double width) //正方形
{
this(width,width);
}
public Rectangle()
{
this(0,0);
}
public double area() //计算面积,实现area 接口的抽象方法
{
return this.width*this.length;
}
public double perimeter() //计算矩形周长
{
return(this.width+this.length)*2;
}
public String toString()
{
return"一个矩形,长度"+length+",宽度"+width",面积"+area()+",周长"+perimeter();
}
public ststic void main(String args[])
{
System.out.println(new Rectangle(10,20).toString());
}
}
问题不少
1,protect ――>protected
2,return "一个矩形,长度" + length + ",宽度" + width + ",面积春顷" + area() + ",周长"
+ perimeter();//这句少了一个连接号碧缓“+”,这句我已经帮你加上了
3,ststic――>static

以上问题,扒慧陆如果你用eclipse或用NetBeans来编辑的话,根本不会出现这些错误,出错会提示
嗯!你是初学者吧,要不然也不会敲错这么多稿码关键字。

1、protect 》》键埋哪protected
2‘、return"一个矩形,长度"+length+",宽度"+width+",面积"+area()+"液者,周长"+perimeter();
3、ststic》》static

如果你是初学者,我觉得你有必要试试用一些编辑工具比如:editplus,eclipse等,不过个人建议,初学用editplus比较好,尽管他没有eclipse那么强大的辅助功能,但是对于初学者的掌握java的一些必要的配置是很有帮助的。
没有设孙启置入口类吧
运行或者生成核含jar时要指定main在则氏如哪个类里

另外 你的main入口也写错了
public ststic void main

应该是 static
您好,您高猛单旅罩位main方法戚镇桥写错了,应该如下:public ststic void main(String[] args) { }
public ststic void main(String args[])
写升贺错了吵猜派
应该兆樱是
public static void main(String[] args)
← 上一篇: 下一篇: →