Java generics type binding. Why isn't this compiling?

Viewed 1236

Given this generic function:

<T> List<T> function() { return null; }

Why does this compile

List<String> l = function();

While this does not?

List<String> l = (List<String>) function();
7 Answers
Related