日期:2014-05-20 浏览次数:20804 次
public class JavaTest
{
private static void change(Integer i)
{
i = 3;
}
public static void main(String argv[])
{
Integer i = new Integer(1);
change(i);
System.out.println(i);
}
}
/**
* The value of the <code>Integer</code>.
*
* @serial
*/
private final int value;
/**
* Constructs a newly allocated <code>Integer</code> object that
* represents the specified <code>int</code> value.
*
* @param value the value to be represented by the
* <code>Integer</code> object.
*/
public Integer(int value) {
this.value = value;
}
i = 3; // 请问这句话是什么过程?
Integer a = new Integer(1);
Integer b = a; // 没错b和a同时指向一个对象
b = 3; // 这句话说明什么?他只是修改了b的引用,对a的值有影响吗?
System.out.println(a); // 你试试