Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic syntax symbol <~> [duplicate]

Tags:

java

generics

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<~>();

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?

like image 426
4lex1v Avatar asked Dec 17 '22 02:12

4lex1v


1 Answers

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<>();
like image 162
Peter Lawrey Avatar answered Dec 18 '22 17:12

Peter Lawrey