Why Diamond operator was not missed from Right hand side in Java 7?

别来无恙 提交于 2019-11-30 23:31:56

The following code compiles and runs without error.

SoftReference<String> ref = new SoftReference(new Integer(1));
Object o = ref.get();
System.out.println(o); // prints "1"

A raw instance of SoftReference is created. "Raw" means that there is no generic type checking, which is required to allow to mix generics with pre-generics code.

By making the diamond operator implicit, you would break it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!