您的位置:首页 > 编程语言 > Java开发

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

2017-11-17 10:43 591 查看
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());
}
}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string 对象 内存 class
相关文章推荐