why is it
a method with the signature:
public void foo(List<String> string)
cant be called by guavas: foo(Lists.newArrayList())
or java7s: foo(new ArrayList<>())
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Compiler is not capable of inferring correctly what type
Lists.newArrayList()should return. You can tell compiler what type you want byWhy can’t compiler infer the type? Consider these methods
If you have
bar(newObject()), then compiler can’t determine which method it should call. Compiler needs to know the type of the parameter before finding the method to call, even if there is only one possible method currently. Otherwise a new overloading method will break your code.