简体   繁体   中英

Java / Groovy generic type inference

I'm writing Groovy (1.8.8) code running under JDK6 and it seems the following is legal:

ConcurrentMap<Foo, Bar> statsRegistry = new ConcurrentHashMap<>()

Why is it permitted to omit the types on the right-hand side? Is this a NEW Groovy feature or would this also be allowed in Java 6?

Groovy 1.8中引入了“ diamond operator”(类型推断),请参阅发行说明中的​​这一项目 ,并且Groovy 1.8在JDK6上可以正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM