| 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: 18670
|
|
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: 32830
|
|
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
|
 |
 |
|
|
subject: Static methods - final
|
|
|