问题与练习:对象

Questions

public class SomethingIsWrong {
    public static void main(String[] args) {
        Rectangle myRect;
        myRect.width = 40;
        myRect.height = 50;
        System.out.println("myRect's area is " + myRect.area());
    }
}
...
String[] students = new String[10];
String studentName = "Peter Parker";
students[0] = studentName;
studentName = null;
...

Exercises

public class NumberHolder {
    public int anInt;
    public float aFloat;
}

检查一下你的答案。

首页