“Access objects by their interfaces” is good practice, as stated in Effective Java. So for example, I prefer
List<String> al = new ArrayList<String>();
above
ArrayList<String> al = new ArrayList<String>();
in my code. One of the nasty things is that if I type ArrayList<String> al = new and then press Ctrl + Space in Eclipse, I get ArrayList<String>() as propostal. But if I type List al = new and then press Ctrl + Space, I get only propostal to define an anonymous inner class, but not propositions like new ArrayList<String>() , which is 99% more, or, for example, new Vector<String>() .
Question : Is there a way to get subclasses as propositions for generic types?
java generics eclipse autocomplete effective-java
Avrdragon
source share