E
edi
Hi,
I want to create my ArrayList which contains only objects from a
paricular class, MyClass. I extends ArrayList and override only method
"add(int,object)" as follows:
public void add(int index, Object m) {
if ( !(m instanceof MyClass)){
return;//here I want to throw an exception
}
super.add(index,m);
}
but I want to throw an exception if the object is not from my class.
super.add(...) throws only IndexOutOfBoundsException. What can I do in
this situation? Are there any other possibilities to cope with this
situation?
I want to create my ArrayList which contains only objects from a
paricular class, MyClass. I extends ArrayList and override only method
"add(int,object)" as follows:
public void add(int index, Object m) {
if ( !(m instanceof MyClass)){
return;//here I want to throw an exception
}
super.add(index,m);
}
but I want to throw an exception if the object is not from my class.
super.add(...) throws only IndexOutOfBoundsException. What can I do in
this situation? Are there any other possibilities to cope with this
situation?