关于Wrapper Class

public class RunTest{
	public static void main(String[] args) {
		Integer ten=new Integer(10);
		Long nine=new Long(9);
		System.out.println(ten+nine);
		int i=1;
		System.out.println(i+ten); 
	}
}

大家觉得这道题会输出什么?会不会Error?
刚开始我看到的答案是:Error,解释如下:
The wrapper classes cannot be used like primitives.

Wrapper classes have similar names to primitives but all start with upper case letters.Thus in this case we have int as a primitive and Integer as a wrapper.
The objective do not specifically mention the wrapper classes but don't be surprised if they come up .

但是当我真正在试验之后发现竟然可以输出:19、11;
想了想,可能此题是jdk1.4时候的吧,自从v5之后自动拆装箱,就可以输出结果了,应该是这样的。

大家也讨论下。

你可能感兴趣的:(UP)