Java Program using a final class


In this program, You will learn how to implement a final class in java.


final class Test { 
   //statement
}

Example: How to implement a final class in java.

final class Main {

     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