值传递和对象传递

首先是下面的代码:
public static void main(String[] args) throws Exception {
		String a = "oldString";
		int b = 0;
		EnterBean bean = new EnterBean();
		bean.setString("oldString");
		change(a, b, bean);
		System.out.println("a:"+a+"'"+"b:"+b+"'"+"bean:"+bean.getString());
	}
public static void change(String a,int b,EnterBean bean){
		a = "new string";
		b = 10;
		bean.setString("new");

得到的结果是
引用


a:oldString'b:0'bean:new




你可能感兴趣的:(bean)