I have a class that is extending Java\'s ArrayList. I\'m currently using Java build 1.6.0_22-b04. Looks like this:
public class TokenSequence extends ArrayList&
First of all, in the current implementation it will go to infinite recursion when you will try to call add function with instance of TokenSequence. Did you mean to call "addAll" in that case?
Second, forget about
void add(Object)
in you case you need to add 2 methods (make them return boolean, if you want to be consistent):
public void add(String o) {
add(new Token(o.toString()));
}
public void add(TokenSequence t){
addAll(t);
}
and the add(Token) is already implemented by ArrayList
on the other hand, if you want a single method, you can declare, for example:
public void add(Serializable t)
this method will be called for both TokenSequence and String. unfortunately to make the same method executed for Token (as oppose to the one provided by ArrayList), you will need:
i.e:
add((Serializable)new Token())