Final keyword in Java programming language
- Home
- Keyword in Java
- Final keyword in Java programming language
- On
- By
- 0 Comment
- Categories: Keyword in Java
Final keyword in Java programming language
Final keyword in Java programming language
In tis tutorial,We will discuss about Final keyword in Java programming language
final is a Java keyword, it is used to restrict the user, When the variable is defined as final, you can not changed the value of the final variable. So its constant The final key word can be use 3 situations
know more about final, click Usage of final in Java programming language
When the method is defined as final method – prevent method over riding
When the method is defined as final method – prevent class inheritance
final variable
final variable define as
Syntax
<final><data_type><variable_name>=value;
Example
final int MY_AGE=23; //this value can not be changed
final method
final method define as
Syntax
<final><return_type><method_name>
Example
final void demo(){}
final class
final class define as
Syntax
<final><class><class_name>{}
Example
final class parent{}
There are other Java language keywords that are similar to this keyword
float keyword in Java
Suggested for you
Usage of this statement in the Java language
Usage of final in Java programming language