I
ipor20
I'm trying to find a way of allowing me to create typed Vectors - in
the past I've been able to use generics to achieve this (for example
new Vector<Integer>) but at the moment I'd like to declare a Vector
field in a base class (with no particular type or maybe another base
class) and then assign a type to it in the constructor of classes
extending the base class - I was wondering if this is possible - I'm
thinking along the following lines...
class BaseContainer{
Vector children = new Vector() ;
}
class Type1Container extends BaseContainer{
public Type1Container(){
children = new Vector<Type1>() ;
}
}
class Type2Container extends BaseContainer{
public Type2Container(){
children = new Vector<Type2>() ;
}
}
Any ideas welcome
P@
the past I've been able to use generics to achieve this (for example
new Vector<Integer>) but at the moment I'd like to declare a Vector
field in a base class (with no particular type or maybe another base
class) and then assign a type to it in the constructor of classes
extending the base class - I was wondering if this is possible - I'm
thinking along the following lines...
class BaseContainer{
Vector children = new Vector() ;
}
class Type1Container extends BaseContainer{
public Type1Container(){
children = new Vector<Type1>() ;
}
}
class Type2Container extends BaseContainer{
public Type2Container(){
children = new Vector<Type2>() ;
}
}
Any ideas welcome
P@