File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes static final methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static final methods" Watch "static final methods" New topic
Author

static final methods

faisal usmani
Ranch Hand

Joined: Jan 14, 2006
Posts: 139
hi,

public static final abc() is a valid method I cannot understand what signify to makes static method a final .Anyhow a static method cannot be overridden.

Can anyone explain why we declare a static method final.


thanx in advance
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780

It stops you from declaring a static method with the same name and parameter types in a derived class. Why do this? I don't see the need for it and I've never seen it used. Does anyone do this?


There is no emoticon for what I am feeling!
faisal usmani
Ranch Hand

Joined: Jan 14, 2006
Posts: 139
no idea !!! :roll:


There is no duty more obligatory than the repayment of kindness.
[ May 11, 2006: Message edited by: faisal usmani ]
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
This might be a reason for someone to make a static method final:

The call to f() im main resolves to A's version of f, but when you uncomment B's version of f, it hides A's f. I'm not worried about this because I think I'm careful when I invoke a static method to use the name of the class that introduces it.
[ May 11, 2006: Message edited by: Jeff Albertson ]
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4344
    
    8

John G Wright,
Your post was moved to a new topic.
 
Consider Paul's rocket mass heater.
 
subject: static final methods
 
Similar Threads
Stateless Session Bean variables static or non-static.
Overriding
Why can the final modifier be used with static methods?
can main be declaired final ? why
static final method