Quick question about syntax in Java. I want to take a Set and return a List in a static method for a library. The following gives a compiler error and I don’t know why:
public static List<T> asList(Set<T> keySet)
{
// TODO Auto-generated method stub
return null;
}
The message is “T cannot be resolved to a type”. But isn’t that the syntax for a generic type in Java?
For a generic method you need to put the type
<T>before the return argument also e.g.