Autocomplete for generic types in Eclipse

autocomplete, eclipse, effective-java, generics, java

Solution

I would suggest simply writing the expression first and then hitting `Ctrl+2, L`. Then you can name the variable, followed by `Enter, Down, Enter`. Done.

Problem

"Refer to objects by their interfaces" is a good practise, as mentioned in Effective Java. So for example i prefer ``` List<String> al = new ArrayList<String>(); ``` over ``` ArrayList<String> al = new ArrayList<String>(); ``` in my code. One annoying thing is that if i type `ArrayList<String> al = new` and then hit Ctrl+Space in Eclipse i get `ArrayList<String>()` as propostal. But if i type List al = new and then hit Ctrl+Space i will get only propostal to define anonymous inner class, but not propostals such as `new ArrayList<String>()`, what is 99% the case, or for example new `Vector<String>()`. Question: Is there any way to get the subclasses as propostals for generic types?

Original source