wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes inheriting a static method..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inheriting a static method....." Watch "inheriting a static method....." New topic
Author

inheriting a static method.....

rahul mehra
Ranch Hand

Joined: Aug 20, 2007
Posts: 33
why can't a instance method in the subclass override a static method of the superclass??? why do we get a complie time error???


Thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See if this helps: Overriding vs. Hiding.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52
who decided to make java so confusing??


Still Learing..
Adam Schaible
Ranch Hand

Joined: Oct 04, 2007
Posts: 101
It will make sense later for you..

Statics do not have context - by context, usually we perform behaviors on an object, ie:



In this example, d (Dog object) is the context. Since statics don't have context, the only way we are supposed to reference them is by the class - so for example:



Since I'm not actually creating an instance of service, how exactly would I override it?



Two different methods, get what I'm saying?
[ November 06, 2007: Message edited by: Adam Schaible ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inheriting a static method.....
 
Similar Threads
question about abatract
access to another classs' elements(variables)?
abstract method
interface
(Design Perspective)Static method in interface