Skip to content

Instantly share code, notes, and snippets.

@girishsalaskar
Last active February 5, 2020 10:55
Show Gist options
  • Save girishsalaskar/70607ed6605d3ffa476ec8c6469ba51c to your computer and use it in GitHub Desktop.
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)
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