Final Keyword


// the final class cannot be inherited
public final class FinalClass {


    private final int intVariable = 300;


    //The final method cannot be overridden
    public final void finalColor(){
        System.out.println("final Color");

    //we cannot have setter for the final variable
    //we cannot update the value of the final variable
    public int getIntVariable() {
        return intVariable;



//Creating an object
public class MainClass {

    public static void main(String[] args) {
        FinalClass finalClass = new FinalClass();

Print Print | Sitemap
© 2016 Automation Learn. All rights reserved.