What is Final keyword in Java?

What is Final keyword in Java?

In Java, the final keyword is used to restrict the user. It can be used in various contexts, which ends up restricting what the user can define and use. There are three primarily ways in which a Final keyword can be applied.

  1. Variable: when a variable is made final, it becomes constant, which means that once assigned a value of the variable can never be changed.
  2. Method:  If any method is made finale, it means that it cannot be overridden by subclasses.
  3. Class: In any class is made final, it means that it cannot be extended.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.