struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Micael <caraun...@harbornet.com>
Subject RE: [OT] Use of Static Methods
Date Wed, 09 Jul 2003 21:31:45 GMT
This use of "overriding" is mistaken.  It is the wrong technical term. You 
can tell it does not override by building a driver and seeing results with 
the wrongly called "overridden" method.  You will run the method from the 
parent class if you use a wrongly called overridden static method "static 
String do()" in the child class.

Thus,

Parent instance1 = new Child();
instance1.do();

will return the results of the Parent implementation of do() and

Child instance2 = new Child();
instance2.do();

will return the results of the Child implemenation of do(), so, and this is 
NOT MERE SEMANTICS, the child static method DOES NOT OVERRIDE the parent 
method.

At 03:12 PM 7/9/03 -0400, you wrote:
>Perhaps everyone is correct here. Technically, as Brian showed, the language
>does not prevent you from overriding a method signature in a subclass,
>however, behaviorally, it will not completely behave like an overridden
>method. Like I pointed out in a previous email, you will not get polymorphic
>behavior with the method. As Kris pointed out it is hiding the behavior of
>the parent class.
>
>I hope this satisfies everyone's points on this topic now.
>
>Regards,
>
>Richard
>
>-----Original Message-----
>From: Brian Lee [mailto:brian_a_lee@hotmail.com]
>Sent: Wednesday, July 09, 2003 12:02 PM
>To: dgraham@apache.org; struts-user@jakarta.apache.org
>Subject: RE: [OT] Use of Static Methods
>
>
> >From: David Graham <grahamdavid1980@yahoo.com>
> >Reply-To: dgraham@apache.org
> >To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> >
> > >
> > > 2) It is not correct to say that static methods can't be overriden.
> > > They can be overridden with another static method. You can't
> > > override a static method
> > > to be non-static, however.
> >
> >That's incorrect.  Static methods cannot be overridden.
>
>Actually, that's incorrect. Static method can be overridden.
>
>foo.java
>public class foo{
>public static void bar(){}
>}
>
>baz.java
>public class baz extends foo{
>public static void bar(){}
>}
>
>compiles
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*
>http://join.msn.com/?page=features/junkmail
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org



LEGAL NOTICE

This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank 
you  



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message