get runtime class and cast object to it?

Hi,

publicinterface Msg

{

...

}

...

Msg msg=msgLib.get(msgType);

Msg msg2=msg.clone();//problem! cannot find clone in x.y.Msg!

...

Shouldn't msg be resolved to the implementing class (MsgReply for example) and use the "clone()" method, that i have declared in that class -which overrides the one of Object class?

If no, is there a way to find the runtime class -probably use "getClass"- and cast to it? How?

Thanks

[640 byte] By [uiga] at [2007-11-26 12:21:17]
# 1
Msg msg2 = (MsgReply)msg.clone();
CaptainMorgan08a at 2007-7-7 15:12:39 > top of Java-index,Archived Forums,Socket Programming...
# 2
There are many implementing classes; i want to get the runtime class. Something like:(msg.getClass())msg.clone();Message was edited by: uig
uiga at 2007-7-7 15:12:39 > top of Java-index,Archived Forums,Socket Programming...