I know that using generic in an assignment, a method can implicitly know the type of the return type by looking at the type of the left hand side variable.
Example from Google Collection:
List<String> l = Lists.newArrayList()
My question is why it doesn't work for a method or higher type of inference?
Example:
List<List<String>> ll = Lists.newArrayList();
ll.put(Lists.newArrayList()); // doesn't work
Is this specified in the JLS? If yes, why? If no, then is this a kind of improvement that I can expect from Java 7?
This annoyed me because seems that we have a problem in Java like I have problem in Delphi a long time ago where I can't do chained method call like:
C c = a.b().c();
In Delphi (IIRC), you have to do:
B b = a.b();
C c = b.c();
Looks like a 'dejavu'