Why we need <T> before void?

97 Views Asked by At

I'm learning Java generics. I found the first <T> to be difficult to understand: if the method returns nothing, what does the <T> before void means?

public static <T> void fromArrayToCollection(T[] a, Collection<T> c) {                          
    for (T o : a) {
        c.add(o);
    }
}
0

There are 0 best solutions below