UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why string objects are immutable?

Asked by Last Modified  

12 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Expert in Java/J2ee technology

We cannot change the String object because String is immutable. Vice-versa is not the same. String is immutable because of the security. Sting is storing the data in String Pool which can be used by multiple reference of String object. So during creation of String it is searching in the Pool the value...
read more
We cannot change the String object because String is immutable. Vice-versa is not the same. String is immutable because of the security. Sting is storing the data in String Pool which can be used by multiple reference of String object. So during creation of String it is searching in the Pool the value is present or not. If present object is pointing to the String. So multiple object can refer to single value. read less
Comments

Computer Classes

String objects are immutable because of we can't change,if you try to alter their values, another object gets created
Comments

12 years of MNC company work experience on java ,J2ee technologies

In java the string objects are immutable ,that we can't change the object value .It provides the security in java.Once we create and passed the parameter as string ,In between the components nobody modify the String objects.It gives the security in communication among components in distribution envir...
Comments

Trainer

If the strings are not immutable, it would lead to serious security threat as it would allow to changes in the file containing it. Mutable strings could cause security problem in Reflection too, as the parameters in the methods being inspected are strings. Therefore in all these cases hashcode of the...
read more
If the strings are not immutable, it would lead to serious security threat as it would allow to changes in the file containing it. Mutable strings could cause security problem in Reflection too, as the parameters in the methods being inspected are strings. Therefore in all these cases hashcode of the string is frequently used in Java to know if its value is changed knowingly or unknowingly. read less
Comments

Tutor

Strings are immutable once created cannot be changed and hence cannot be eliminated but string builders are mutable.
Comments

Expert in Java/J2ee technology

The string is Immutable because String objects are stored in String pool. String pool are shared between multiple clients there is always a risk to updating the data. When a string is created and if the string already exists in the pool, the reference of the existing string will be returned, instead...
read more
The string is Immutable because String objects are stored in String pool. String pool are shared between multiple clients there is always a risk to updating the data. When a string is created and if the string already exists in the pool, the reference of the existing string will be returned, instead of creating a new object and returning its reference. read less
Comments

Java Tutor

String class is made Immutable to provide more efficiency. Its not that all time new object is created , there is concept of String Pool which is used for look up the existing objects
Comments

Trainer

Very good questions thanks for asasking The string is Immutable in Java because String objects are cached in String pool. Since cached String literals are shared between multiple clients there is always a risk, where one client's action would affect all another client. For example, if one client changes...
read more
Very good questions thanks for asasking The string is Immutable in Java because String objects are cached in String pool. Since cached String literals are shared between multiple clients there is always a risk, where one client's action would affect all another client. For example, if one client changes the value of String "Test" to "TEST", all other clients will also see that value as explained in the first example. Since caching of String objects was important from performance reason this risk was avoided by making String class Immutable. read less
Comments

Trainer

String is immutable cause of security parameters are typically represented as String in network connections, database connection urls, usernames/passwords etc. If it were mutable, these parameters could be easily changed. In Synchronization and concurrency making String immutable automatically makes...
read more
String is immutable cause of security parameters are typically represented as String in network connections, database connection urls, usernames/passwords etc. If it were mutable, these parameters could be easily changed. In Synchronization and concurrency making String immutable automatically makes them thread safe thereby solving the synchronization issues. Caching: when compiler optimizes your String objects, it sees that if two objects have same value (a="test", and b="test") and thus you need only one string object (for both a and b, these two will point to the same object). Class loading: String is used as arguments for class loading. If mutable, it could result in wrong class being loaded (because mutable objects change their state). read less
Comments

Trainer

In java, string objects are immutable. Immutable simply means unmodifiable or unchangeable. Once string object is created its data or state can't be changed but a new string object is created.
Comments

View 10 more Answers

Related Questions

What is IBM RAD(Rational Application Developer)?
RAD means Rational Application Developer for WebSphere Software accelerates the development and deployment of Java, Java EE, Web 2.0, mobile, OSGi, portal and service-oriented architecture (SOA) applications....
Ashish
Is java a frontend or a middleware technology or both?
It's a programming language which is used to write application programs and is independent of platform.
Neha
0 0
5
Is it good to go for a Java coaching center and learn Java (with advanced Java) to improve my programming skills?
yes, Please check the Institute reviews and discuss with the tutor, what topics were covered in class. Ask about the practicals session and how many hours/duration of the course.
Gerda
0 0
5
Who can provide good Java training with real-time but not institute?
I provide industry specific training to students. If interested check my profile. I used to provide training in Big Data, Java, Scala and Spark too.
Sridevi
0 0
6
What are the benefits of attending Java coaching classes?
Today Java is the basic requirement for the software industry by learning advanced concepts in java you will have a very good job prospective's. Even if you want to learn BIg Data, testing tools ect.....
Selvi
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Tips of learning Java Language/Other Programming Languages
1.You should know the basic concept: If we talk about programming languages so basic concept are same in all the high level languages. So you should know the basic concept firstly then you can easily understand...
I

ICreative Solution

0 0
0

Class and Objects in Java
Class is a template or a blueprint which is used to describe an object. On other hand Object is a reference of a class which follows all the stuff written inside the class. How about taking the whole tour in the following video


Importance of Constructor's Visibility.
While developing program or implementing Singleton pattern we have learnt to mention constructor as private and known reason is -> to blocked its direct call from outside of class. But did we think...
M

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

Recommended Articles

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more