I have the following in my top class working like a charm:
public class TestA<E extends Test>
{
List<Vector<E>> list;
String name, location;
TestA(String name, String location)
{
this.name = name;
this.location = location;
list = new ArrayList<Vector<E>>();
}
void populate(Test[] arr)
{
for(Vector<E> vk : list)
{
// Code here...
}
}
}
class OrderedTest<E extends Test> extends TestA {
OrderedTest(String name, String location)
{
super(name, location);
}
void populate(Test[] arr)
{
for(Vector<E> vk : list) // ERROR: Cannot convert from element Object to Vector<E>
{
// Code here...
}
}
}
When i try to extend populate() in my subclass i basically want the same method only here i want things ordered so i will pull each Vector in a quicksort method but i dont get any other problems apart from: // ERROR: Cannot convert from element Object to
EDIT: Should i have to implement Iterator for TestA ?
As coded, the two uses of “E” as a generic parameter are independent and disconnected.
Vector<E>in one class does not mean the same asVector<E>in the other.Change the subclass declaration to:
and the E in the superclass declarations is the same E as in OrderedTest.