public static <T> List<T> listAndCast(Query query) {
@SuppressWarnings("unchecked")
List<T> list = query.list();
return list;
}
In the following line:
public static <T> List<T> listAndCast(Query query) {
Why do we need <T> ?
The
<T>tells Java that it is a generic method that defines its own type parameter, instead of relying on one defined for the entire class, e.g.public class Stuff<T> {}