You will get the method from the child.
The actual object you are referring to has not changed .... it's the same
horse (instance in memory), just a different jockey (reference label).
Peter.




                                                                                       
                           
                      "Luc Foisy"                                                      
                           
                      <[EMAIL PROTECTED]        To:       "jdjlist" <[EMAIL 
PROTECTED]>               
                      -magic.com>                 cc:                                  
                           
                                                  Subject:  [jdjlist] casting problem 
(maybe)                     
                      25/02/03 20:33                                                   
                           
                      Please respond to                                                
                           
                      "jdjlist"                                                        
                           
                                                                                       
                           
                                                                                       
                           





If I cast an object as its superclass, then call a method that has been
overrided
in the child, will it call the method from the child or the superclass??
Such as:

public class TMHTTPDataObject
{
             String value = "";

             public void setValue(String _value)
             {
                         value = _value;
             }

             public String getValue()
             {
                         return value;
             }
}

public class TMHTTPDateField
{
             public void setValue(String _value)
             {
                         value = dateConvert(_value);
             }
}

if( panelItems.elementAt(i) instanceof TMHTTPDataObject )
{
             TMHTTPDataObject temp = (TMHTTPDataObject)
panelItems.elementAt(i);
             if( temp.getLinkedField().equals(_linkedField) )
             {
                         temp.setValue(_value);
                         break;
             }
}


Should getValue return the string straight up or the dateConverted string??

---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
http://www.sys-con.com/fusetalk





---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk

Reply via email to