This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Static methods - final Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static methods - final" Watch "Static methods - final" New topic

Static methods - final

Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145

I read that

static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object.

I cannot make a sense of this. I want to try some code which explains this. Any help ?

* implicitly final ?
* overriding is done based on the type of the object ?

Regards,<br />Arnab
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Well, it's not true. Static methods aren't implicitly final. Where did you read this? I suggest you simply disregard this statement, as it will just lead to confusion.

It's possible (mmmm, probable) that the author was trying to say that static methods can't be overridden. This is true, but it's not the same as being final. See here for more about "overriding" static methods if you want to learn more.

"I'm not back." - Bill Harding, Twister
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Thanks Jim. I will ignore that statement.

How about the next one ? "overriding is done based on the type of the object ?" - what does this mean ? If this is not correct either - I better give up the article that I am reading on the net
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43905
I think "attached to the object" means that different objects are formed from different classes, and object A might be from a subclass of the class object B is from, so the two objects have different methods.
I think your suggestion of reading something else might be a good one
Have you checked out Aspose?
subject: Static methods - final
It's not a secret anymore!