Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static final methods

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John G Wright,
Your post was moved to a new topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic