章节内容 : java 对象
具体内容:1、练习体会java语句,并区别实例变量与类变量。
代码实现:
import java.awt.Point;
class SetPoints{
public static void main(String[] args){
Point location = new Point(4, 13);
System.out.println("Starting location:");
System.out.println("X equals " + location.x);
System.out.println("Y equals " + location.y);
System.out.println("\nMoving to (7, 6)");
location.x = 7;
location.y = 6;
System.out.println("\nEnding location:");
System.out.println("X equals " + location.x);
System.out.println("Y equals " + location.y);
}
}
结果显示: