作业帮 > 综合 > 作业

what is wrong with the following program?

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/24 21:45:24
what is wrong with the following program?
ublic class SomethingIsWrong {
public static void main(String[] args){
Rectangle myRect;
myRect.width = 40;
myRect.hight =50;
System.out.println('myRect's area is"+myRect.area());
}
Rectangle myRect;
这里没初始化,改成
Rectangle myRect = new Rectangle(这里输入构造方法的参数,如果没参数就不用输);
记住,要用到一个实例,必须先实例化一个实例.
再问: what is wrong with the following interfface public interface something is wrong{ void aMethod(int aValue){ System.out.println("hi mom"): } }
再答: 接口里面的方法,不能有方法体,改成: public interface somethingiswrong{ void aMethod(int aValue){} }
再问: somethingiswrong是我打错了,没空格
再答: public interface somethingiswrong{ void aMethod(int aValue); }