4

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?

4lex1v
  • 21,367
  • 6
  • 52
  • 86

1 Answers1

12

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<>();
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130