Learn Pain Less

HomeOur TeamContact
Java
What is the use of final keyword in JAVA
Pawneshwer Gupta
Pawneshwer Gupta
March 21, 2015
1 min
What is the use of final keyword in JAVA

Final keyword in java

Final keyword is used to make member’s value unchanged. Simple definition of final keyword is to make variable’s values non-changeable. Once you declare any member as final you cannot modify it. To make any member as final we simply need to put final keyword before data type.

Example of final keyword:

final int a = 10;

Variable/member marked as final should be initialized at the time of declaration. The reason is that value of final variable is fixed, so we need to provide value at the time of declaration.

Can we modify final members after declaration?

Yes, we can modify final members inside Constructor. Because Constructor called when class is created and it will also initialize final variables.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

startfinal keywordjava tutorial

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

Working with Files, Folders java
Working with Files, Folders java
March 25, 2015
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media