Java对象在内存图示

来源:互联网 发布:ubuntu ibus 安装 编辑:程序博客网 时间:2024/05/01 17:38
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;    }}


左边模板是在栈里面存储,堆一般是动态存储

0 0
原创粉丝点击