Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. public foo() { first = new T(); second = new T(); } //ERROR
  2.  
  3. foo<String> f = foo.makeFoo(String::new)
  4.  
  5. public static <T> foo<T> makeFoo(Supplier<T> constr)
  6. {
  7. return new foo<>(constr.get(), constr.get());
  8. }
  9.  
  10. Error:(35, 38) java: method makeFoo in class generic.foo<T> cannot be applied to given types;
  11. required: java.util.function.Supplier<T>
  12. found: Integer::new
  13. reason: cannot infer type-variable(s) T
  14. (argument mismatch; incompatible parameter types in method reference)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement