Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
public class Main { final int x = 10; public static void main(String[] args) { Main myObj = new Main(); myObj.x = 25; // will generate an error System.out.println(myObj.x); } }
Main.java:6: error: cannot assign a value to final variable x
myObj.x = 25;
^
1 error