Suppose I have an easy way to handle two lists:
public static <B> void foo(List<B> list1, List<B> list2) { }
And I want to call it like this:
foo(ImmutableList.of(), ImmutableList.of(1));
This does not compile because javac not smart enough to realize that I was trying to create two lists of integers. Instead, I should write:
foo(ImmutableList.<Integer>of(), ImmutableList.of(1));
How do I change the declaration of foo so that the first version works as well as the second?
Derek thurn
source share