class Point { int x; int y; void display() { System.out.printf("(%d,%d)\n",x,y); } }class Line { Point start; Point end;}class OOP { public static void main(String[] args) { Point a; Point b; a = new Point(); a.x = 2; a.y = 1; b = new Point(); Point c = a; a.display(); b.display(); c.display(); Line l = new Line(); l.start = a; l.end = b; }}
左边模板是在栈里面存储,堆一般是动态存储