M
mabramso
Right now, if I get an object of a generalized class, for example
Message, I have to do an instanceof to cast the object to a more
specialized class and then call the specialized method with an
appropriate cast. For example:
public void receiveMessage (Message m) {
if (m instanceof StopMessage)
parseMessage((StopMessage) m);
}
Is there a way to get rid of those kindof stub methods and just code
the specialized methods? Those "if" can get pretty unwieldly. I do
have 1.5 but I don't know if generics make a difference there.
Thanks,
myriam
Message, I have to do an instanceof to cast the object to a more
specialized class and then call the specialized method with an
appropriate cast. For example:
public void receiveMessage (Message m) {
if (m instanceof StopMessage)
parseMessage((StopMessage) m);
}
Is there a way to get rid of those kindof stub methods and just code
the specialized methods? Those "if" can get pretty unwieldly. I do
have 1.5 but I don't know if generics make a difference there.
Thanks,
myriam