wood burning stoves 2.0*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static methods - final" Watch "Static methods - final" New topic
Author

Static methods - final

Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Hi,

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
Wanderer
Sheriff

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
Sheriff

Joined: Oct 13, 2005
Posts: 38513
    
  23
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
CR
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Static methods - final