Java, Collection constructor

老子叫甜甜 提交于 2019-12-02 04:06:29

They are the same in java 7 where the diamond operator <> was introduced. In older versions of java the diamond operator will not work.

The diamond operator brings type inference to constructors. Type inference on generic methods is available in java 5 and higher. Prior to java 7, to create a generic class using the compiler's type inference you had to use generic factory methods like static <K,T> Map<K,T> createMap().

First one will only work in Java 7, the second one from Java 5+

No difference at all..! Its just a language construct. <> is newly introduced operator known as diamond operator from java 7.

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