Java Program using final variable


In this program, You will learn how to implement final variable in Java.


final int x = 10;


Example: How to implement final variable in Java

Run it Now
class Main {

    final int x = 10;

    void display() {
        System.out.println("x value is :" + x);
    }

    public static void main(String args[]) {
        Main t = new Main();
        t.display();
    }
}

Output:

x value is :10