Riduidel is right that the problem is that you have not yet announced T
Depending on what you want to do with the contents of the list, most likely you can just use a wildcard. List<?> viewList will work if you get an Object out of it; or List<? extends IListener> List<? extends IListener> allows you to pull out IListeners, etc.
In general, you don't need a generic parameter if it appears only once inside your method, and you should use a wildcard instead. If it appears several times, for example, you delete things from the list and assign them to variables of type T , then you really need a template, and you have to parameterize your method as Rididel suggests .
source share