A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java 8 in Action
this week in the
inheriting a static method.....
Joined: Aug 20, 2007
Nov 04, 2007 23:22:00
why can't a instance method in the subclass override a static method of the superclass??? why do we get a complie time error???
Joined: Aug 31, 2004
Nov 04, 2007 23:49:00
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."
Joined: Sep 05, 2007
Nov 05, 2007 14:42:00
who decided to make
Joined: Oct 04, 2007
Nov 05, 2007 14:50:00
It will make sense later for you..
Statics do not have context - by context, usually we perform behaviors on an object, ie:
Dog d = new Dog(); d.run();
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:
subject: inheriting a static method.....
question about abatract
access to another classs' elements(variables)?
(Design Perspective)Static method in interface
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014