Last active
February 5, 2020 10:55
-
-
Save girishsalaskar/70607ed6605d3ffa476ec8c6469ba51c to your computer and use it in GitHub Desktop.
The final object demonstration (Description is here : https://codewander.blogspot.com/2020/01/the-final-keyword-in-java.html)
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
import java.awt.Point; | |
public class MyClass { | |
static final Point p = new Point(0,0); | |
public static void main(String args[]) { | |
p.x = 10; //Will run successful | |
System.out.println(p); | |
p = new Point(10,0); // Will give compile time error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment