----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
------------------------------------------------------------------------------------<BR>Velmurugan Periasamy<BR>Sun Certified Java Programmer for Java 2 Platform<BR>Sun Certified Web Component Developer for J2EE platform<BR>Sybase Certified EAServer Developer (similar to jCert level 3)<BR>------------------------------------------------------------------------------------<BR>Study notes for Sun Java Certification<BR><A HREF="http://www.geocities.com/velmurugan_p/" TARGET=_blank rel="nofollow">http://www.geocities.com/velmurugan_p/</A><BR>------------------------------------------------------------------------------------
Originally posted by bill bozeman:
The best way to understand this is to think what happens when you override a method. If you have a Parent class name A and a child class that extends A named B, then you create an instance like this:
A a = new B();
perfectly legal and used all the time. Then when you call a method like a.aMethod();, if it is an overridden method the body from class B() runs because of late-binding. But with a static method, you get don't get the method body of B() but of A() because it is not overriding the method, it is hiding it.
----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
8.4.6.1 Overriding (by Instance Methods)
An instance method m1 declared in a class C overrides another method with the same signature, m2, declared in class A if both
1. C is a subclass of A.
2. Either
* m2 is non-private and accessible from C, or
* m1 overrides a method m3, m3 distinct from m1, m3 distinct from m2, such that m3 overrides m2.
8.4.6.2 Hiding (by Class Methods)
If a class declares a static method, then the declaration of that method is said to hide any and all methods with the same signature in the superclasses and superinterfaces of the class that would otherwise be accessible to code in the class. A compile-time error occurs if a static method hides an instance method.
----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |