• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

non-overridable methods in JAVA

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic