Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheriting a static method.....

 
rahul mehra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why can't a instance method in the subclass override a static method of the superclass??? why do we get a complie time error???
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps: Overriding vs. Hiding.
 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
who decided to make java so confusing??
 
Adam Schaible
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic