内存练习 - 对象数组Q37 E04
从 Main 的 run 方法 开始绘制内存
在每个检查点,检查你画的内存是否跟答案一致
练习 1
1 2 3 4 5 6 7 8 9 10 11 12 public class Point { public int x; public int y; public Point() { } public Point(int x, int y) { this.x = x; this.y = y; }}
1 2 3 4 5 6 7 8 9 public class Driver { public static void main(String[] args) { Point[] points = new Point[3]; for (int i = 0; i < 3; i++) { points[i] = new Point(i, i); } // 检查点 }}
检查点 答案

练习 2
根据下方的代码,为 每个检查点 绘制 在那时刻的 内存图
1 2 3 4 5 6 7 8 9 10 11 12 public class Point { public int x; public int y; public Point() { } public Point(int x, int y) { this.x = x; this.y = y; }}
1 2 3 4 5 6 7 8 9 10 11 12 public class Driver { public static void main(String[] args) { Point[] points = new Point[3]; Point current = new Point(0, 0); for (int i = 0; i < 3; i++) { current.x = i; current.y = i; points[i] = current; } // 检查点 }}
检查点 答案
