I'm Trying to modify Java Vector to raise size if im accessing an element bigger than the vector's size. And to insert a new element if im accessing a not initialized element.
Eclipse throws cannot instantiate the type Obj.
public static class Vec<Obj> extends Vector<Obj> {
@Override
public Obj set(int a, Obj b) {
if (super.size()<=a) super.setSize(a+1);
return (Obj) super.set(a,b);
}
@Override
public Obj get(int a) {
if (super.size()<=a) super.setSize(a+1);
if (super.get(a)==null) super.insertElementAt( new Obj() , a);
return (Obj) super.get(a);
}
public Vec () {
super();
}
}