Integer ki=new Integer("50");
System.out.println(ki);//Here I would expect to print the objects name something like [email protected] but this didn't happen.
ki=3;//Here I would expect an error but this actually works.
当时System.out.println(ki);执行然后50出现在控制台,但是当我打印其他对象时,像[email protected]一些东西出现为什么50出现,而不是像[email protected]?为什么可以在Java中正确打印Integer对象?
虽然ki是Integer类型,所以当我分配3的原始值我应该得到一个错误,但我没有为什么?
了解拳击和自动装箱:http://beginnersbook.com/2014/09/java-autoboxing-and-unboxing-with-examples/ –
你应该去通过Java教程至少要熟悉基本的语言语义。 –
@AndrewLi不幸的是,这篇文章的答案并不真正有帮助。 – xlxs