2 Replies Latest reply: Dec 12, 2006 5:18 PM by 807607 RSS

    get runtime class and cast object to it?

    807607
      Hi,
      public interface 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