Final (Java): Difference between revisions

Content deleted Content added
rescuing dead link
fixing cite
Line 17:
==Final methods==
 
A final [[Method (computer science)|method]] cannot be [[Method overriding|overridden]] or hidden by subclasses.<ref>{{Cite web |title=Chapter 8. Classes |url=https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html |access-date=2024-04-25 |website=docs.oracle.com}}</ref> This is used to prevent unexpected behavior from a subclass altering a method that may be crucial to the function or consistency of the class.<ref>[http{{Cite web |title=Writing Final Classes and Methods |url=https://javadocs.sunoracle.com/docs/booksjavase/tutorial/java/IandI/final.html Writing|access-date=2024-04-25 Final Classes and Methods]|website=docs.oracle.com}}</ref>
 
Example: