KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have defined a Java function: static <T> List<T> createEmptyList() { return new ArrayList<T>(); } One way to call it is like so: List<Integer> myList = createEmptyList(); // Compiles Why can't I call it by explicitly passing the generic type argument? : Object myObject = createEmtpyList<Integer>(); // Doesn't compile. Why? I get the error Illegal start of expression from the compiler.
Tags (comma-separated)
Save Edits
Cancel