提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
具有类实例变量的引用对象
import java.awt.Point;//from N o w J a v a . c o m public class Main { public static void main(String[] arguments) { Point pt1, pt2; pt1 = new Point(100, 100); pt2 = pt1; pt1.x = 200; pt1.y = 200; System.out.println("Point1: " + pt1.x + ", " + pt1.y); System.out.println("Point2: " + pt2.x + ", " + pt2.y); } }