I know that by using generic in an assignment, a method can implicitly know the type of the return type by looking at the type of the left variable.
Example from the Google collection:
List<String> l = Lists.newArrayList()
My question is why it does not work for a method or higher type of output?
Example:
List<List<String>> ll = Lists.newArrayList();
ll.put(Lists.newArrayList());
Is this specified in JLS? If so, why? If not, is this some kind of improvement I can expect from Java 7?
This annoyed me because it seems like we have a problem in Java, as if I have a problem in Delphi a long time ago when I cannot make a call call with a chain like:
C c = a.b().c();
In Delphi (IIRC) you need to do:
B b = a.b();
C c = b.c();
Looks like 'dejavu'
source
share