I am trying to write a generic class definition for class UniCourse
that stores students that are registered in the course.
It creates UniCourse
objects that use student emails as identities (e.g. abc123 :: (Type String
), or student Id :: (Type Integer
).
I'm getting this warning:
unchecked cast required: T[] found: java.lang.Object[]
Could someone explain what this means and how to fix this?
public class UniCourse<T> {
private T[] students;
public UniCourse (int size) {
T[] students = (T[]) new Object[size];
}
}