Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why String is final in Java?

user-image
Question added by Lia Madanat , Senior Programmer , InspireJO
Date Posted: 2017/05/16
Essa Essa
by Essa Essa , Associate Professor , Kirkuk University

Making the class final prevents subclasses that could break

Veenalakshmi PV Plamkudy
by Veenalakshmi PV Plamkudy , Android Developer , Iroid Technologies,Kaloor

final is used by the class loading  mechanism....It profound fundamental security aspects

 Because it is used by the class loading mechanism.

not to be overridden by another classes..

string is immutable.once we instalizeed we can not change its value.

Mahmoud Rashad
by Mahmoud Rashad , Oracle Apps Techno Functional Consultant , NTG, Saudi Ports Authority Project

It is immutable objects, Ther are many advantages of immutable objects as you can share duplicates by pointing them to a single instance.

Nadeem Qasmi
by Nadeem Qasmi , backend,DevOps Engineer , Youcan

java string is the core class anad String class is immutable in Java, The string pool was possible only if the string is made final. As if some variable is referring to String pool's object and somehow it gets modified, then it will lead to a failure.

Final is ued for loading the class 

PREM KUMAR  R
by PREM KUMAR R , Front End Developer

The one reason is all the inputs are get in only the Strings. The String is immutable.

The another reason is security and performance. Once we initialize the string is we cannot change the value.

it is used by the class loading mechanism, and thus have profound and fundamental security aspects.string is a very core class in java

Abdelrahman AlMhisen
by Abdelrahman AlMhisen , Research & Development Manager , Menacast

Requirement of String Pool,  Caching Hashcode, Facilitating the Use of Other Objects, Security, Immutable objects are naturally thread-safe

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.