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

Is it possible to learn java at home without coaching in one month?
It all depends on you. If you are already aware of programming then it is definetly possible to learn java at home. But if learn through a tutor then you can learn easily.
Pritom
0 0
5
Can anyone know if there are tools/apps for representing the objects/classes/methods in the JVM in pictorial way?
rational rose and ibm software architect can be used for design and representation
Raghavendra Reddy
0 0
7
Hi, I am pursuing MBA 1st Year. I want to learn Digital Marketing. Is it right for career growth, or should I choose to learn some other technologies? If yes, please give me your suggestions that help me to get a JOB in the IT Sector.
Hi Sai, To find right career path you need to try things ( Which is long way). I would suggest you to learn multiple things ( implementation is important part) and then find your intrest and dive in to...
Sai
What are the necessary qualifications needed for a Java tutor?
1. Knowledge 2. Good education background 3. Experience in teaching 4. Applications and projects that he has himself worked on 5. The zeal to help students
Darshan
0 0
7
What are the difference between abstract class and Interface?
Abstraction : Hiding unnecessary details of object and shows only essential features of Object to communicate. abstract class : partially defined Object interface :Complete specification of Object class : Complete definition of Object
Ashish

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

Ask a Question

Related Lessons

Implementation: What Is JPA And JPA?
The basic Java framework to access the database is JDBC. Unfortunately, with JDBC, a lot of hand work is needed to convert a database query result into Java classes. JPA allows us to work with Java classes...

Write your first Python program in 10 minutes
1. Download python from python official site search "python download" in google 2. Install in your machine 3. verify using : "python --version" command 4. Write first program using notepad create...

Android : Application Launch time improvements.
For any standard android application, below 3 components play important roles to show 1st interface to user, so that he/she can interact with the app. 1. Custom Application class : Intialize the components...

Java Collection
Collection: The collection provides an architecture like a list where we can store and manipulate the group of items. Through Collections, we can achieve operations such as searching, sorting, insertion,...

What Would Be Life Cycle Of A Fresher After Campus In An IT Company?
1. Basic Technical Training: Since freshers are not subject matter experts so gone through 3 - 6 months basic technical training within Organization. 2. Technical Assessment: HR sends freshers to various...

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