File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

non-overridable methods in JAVA

 
Ankur Pandya
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Anyone can tell me name of some methods which can not be overriden in JAVA..?
Like Static, Final etc....
 
W. Joe Smith
Ranch Hand
Posts: 710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are looking for actual methods, I'm sure there are TONS out there. Therefore, I will direct you to the Java 6 documentaiton here.

If you start digging through classes in there I'm sure you will find many examples.
 
Rajkishore Pujari
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are so many. Example: java.lang.Math class is a final class. so you can not extend it and all the methods in it are final.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quickest way to get a complete list would be to grab a byte-code analyzer and just go through all the jars and look for signatures. I'm not sure why anybody would need a list like this, but that'd be how I'd get it.
 
Matthew Cox
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur Pandya wrote:Hi, Anyone can tell me name of some methods which can not be overriden in JAVA..?
Like Static, Final etc....



Based on your wording, I think what you are trying to ask is, "What type of modifiers can prevent methods from being overriden?"

If my assumption is correct then the answer would be marking something as final (a field modifier).

There are drawbacks to marking anything as final method or variable. So my recommendation is to consider the purpose of the class and the need to mark something as final.


If this is not the case then the resources that the other posters have given would be more than sufficient
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Cox wrote:There are drawbacks to marking anything as final method or variable.


What are all the drawbacks?
 
Matthew Cox
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seetharaman venkatasamy wrote:
Matthew Cox wrote:There are drawbacks to marking anything as final method or variable.


What are all the drawbacks?


variables and methods marked as final have the drawback of the following:

1. Scale of use - Items that utilize final are more commonly data structures or prohibitive supertypes as they cannot be modified (method or object) and can only be assigned a value or implementation (respectively) once.

2. Flexibility - Future builds of your code could have dependencies upon objects, variables, and methods that are marked as final, but conflict with newer code requirements.

3. Incompatibility with Inheritance (as in the item cannot be extended or enhanced in any form)
-Although, I do understand and admit that in most cases, the use of final would be just for this purpose, to prevent modification

I want to make a clear statement though. I only mentioned the "drawbacks" in relation to the possibility of using final haphazardly. If this modifier is used correctly, then drawbacks will not be an issue. But simply using this modifier to restrict access without regards to future modification or needs would be careless at best.

Since the question was semi-vague to begin with (no offense meant to the original poster), I merely wanted to give warning if this was the case for him.

P.s

I bet there are more, but since I possess only so much knowledge =P that is all I can list for now.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic