通用语法符号<〜> [英] Generic syntax symbol <~>
本文介绍了通用语法符号<〜>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用NetBeans或IDEA等IDE,我发现他们正在将泛型类型转换为此符号:
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<~>();
但在简单的编辑器中使用它会导致抛出错误。 BTW Eclipse也不喜欢它。它是否以某种方式与类型擦除机制相关联?
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?
推荐答案
你会在IntelliJ中看到它的颜色不同!
You will see that in IntelliJ its a different colour!
这是因为它使用代码折叠来隐藏代码,但你不能用Java 6这样写它。
This is because it has used code folding to hide the code, but you can't write it this way in Java 6.
在Java 7中,您可以编写
In Java 7 you can write
private final List<String> ar = new ArrayList<>();
这篇关于通用语法符号<〜>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文