Final (Java): Difference between revisions

Content deleted Content added
No edit summary
Bluemoose (talk | contribs)
AWB assisted clean up + tagging
Line 1:
{{Wikify}}
 
Final keyword is used in several different contexts as a modifier meaning that what it modifies cannot be changed in any sense.
 
Line 4 ⟶ 6:
For example,
 
class Sample
{
Line 15 ⟶ 17:
String class is defined final to prevent creating a subclass.
If you try to access the class(which is declared as final class) , then you will get a compiler error.
 
 
Final Method:
 
You can use the final keyword in a method declaration to indicate that the method cannot be overridden by subclasses.
 
Line 29 ⟶ 30:
 
For example:
 
class Myclass
{