I have a task in which I have to implement an add() method for a custom generic list. In my code i have the following structure:
public abstract class MyGenericListAbstract<T> {
protected transient T head;
protected transient T tail;
protected transient int size;
...
}
public final class MyEmptyList<T> extends MyGenericListAbstract {
private T[] list;
...
public final void add(T e)
{
this.getList()[this.size()] = (T) e;
}
...
private T[] getList()
{
return this.list;
}
}
The problem I have for now is that when i try to do this:
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
MyGenericListAbstract <Integer> list0 = new MyEmptyList();
list0.add(new Integer(3));
}
}
I get the following error:

and I cannot figure out why ...
Can anyone please help me?
The entire code is available here, also some documentation about the task here. If you spot some flaws, I would be happy to hear them!
Thanks!
MyGenericListAbstracthave anaddmethod?public final class MyEmptyList<T> extends MyGenericListAbstract. That's using the raw typeMyGenericListAbstract. Trypublic final class MyEmptyList<T> extends MyGenericListAbstract<T>. Likewise you should probably useMyGenericListAbstract <Integer> list0 = new MyEmptyList<>();. Avoid raw types as far as possible.(T) e;whereaseis already a type ofT?