Generic syntax symbol <~> [duplicate]

馋奶兔 提交于 2019-12-23 15:20:54

问题


Working with IDE like NetBeans or IDEA, i've seen that they are converting generic types into this symbol:

private final List<String> ar = new ArrayList<~>();

But using this in a simple editor results in throwing an error. BTW Eclipse also doesn't like it. Is it somehow connected with type erasure mechanism?


回答1:


You will see that in IntelliJ its a different colour!

This is because it has used code folding to hide the code, but you can't write it this way in Java 6.

In Java 7 you can write

private final List<String> ar = new ArrayList<>();


来源:https://stackoverflow.com/questions/9915280/generic-syntax-symbol

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