Last active
September 30, 2018 03:41
-
-
Save Devansh-Maurya/5ff1e18aef2faf1279d12fec395f7c3a to your computer and use it in GitHub Desktop.
Example showing how final prevents method overriding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
final void meth() { | |
System.out.println("This is a final method"); | |
} | |
} | |
class B extends A { | |
void meth() { // ERROR! Can't override. | |
System.out.println("Illegal!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment