public class MyClass {
public static void main(String[] args) {
final int myNum = 15;
myNum = 20; // will generate an error
System.out.println(myNum);
}
}
Result:
MyClass.java:4: error: cannot assign a value to final variable myNum
myNum = 20;
^
1 error