小example说明java的值传递和引用传递,基础变量和对象在内存里的区别,堆栈

来源:互联网 发布:mac 游戏排行 编辑:程序博客网 时间:2024/06/09 08:00
public class ExceptionTest {    public Test2333 txt(){        Test2333 test = new Test2333();        try {            test.setX(1);            test.setY(1);            return test;        }finally{            test.setY(10);        }    }    public class Test2333{        int x;        int y;        public int getX() {            return x;        }        public void setX(int x) {            this.x = x;        }        public int getY() {            return y;        }        public void setY(int y) {            this.y = y;        }    } public static void main(String[] args){     ExceptionTest exceptionTest = new ExceptionTest();     Test2333 test = exceptionTest.txt();     System.out.println(test.getX()+"~~~"+test.getY());    }}
 
阅读全文
0 0