I have the following class:
public class ArrayObjects<E> implements SomeImp<E>{
int maxCapacity, actualSize;
public ArrayObjects(){
maxCapacity = 10;
array = (E[]) new Object[maxCapacity];
}
}
Eclipse marks an error and says the following:
"array cannot be resolved to a variable"
Also it shows some additional details:
-Type safety: Unchecked cast from Object[] to E[]
Does anyone know what am I doing wrong? My goal is to have an array in my class constructor that can hold any kind of object (that's why I am trying to make it generic) but apparently this approach will not work.
Thank you for your help!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…