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 are the booming technologies in US from Job point of view
All the terminologies are good. First of all decide your self you want go as functional consultant or technical. If you have java background Learn Hadoop. Billing rate is very high.
Chandra
How can I learn Java from home?
The best way to learn any technology is to: Step 1- Read in brief about the language from online source. Step 2- Understand basic syntax. Step 3- Take some mini project and start building from scratch...
Divya
0 0
5
I completed my graduation in 2017, now working as an HR Executive in a Consultancy. I want to move to IT Sector. Which course is best for me to learn and get success in life? Please Suggest me
Dear Kumar, My suggestion is to - become good in one programming language - preferably Java and one O/S preferably Linux. Be aware of Open Source systems. Try to identify the opportunities in your existing...
Kumar
Which is best to build web applications: PHP, Python, or Ruby? Why?
I have used almost all of the three language in my web working experience.PHP:It may be not that cool and I think it doesn't rely too much on the framework. Yes, PHP is just a language, but it is the only...
Sunil
0 0
7
Should we learn DBMS and RDBMS without any Java training?
java or i can say any programming language is not required to learn DBMS or RDBMS
Karthik
0 0
6

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

Ask a Question

Related Lessons

How to create a Singleton class?
How to create a Singleton class: Q) What is a singleton class? A) In simple words, a singleton class is a class which can have only one instance at any point of time throughout the application and provides...

Puzzle Game coding
import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.RenderingHints;import...

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Fractional Knapsack
Algorithm - Fractional Knapsack import java.util.Scanner; public class Knapsack01 { public static void main(String args) { Scanner scan = new Scanner(System.in); int...

JAVA - Object Cloning
JAVA - Object Cloning Is the way of creating the same copy of object without calling the class constructor. It means we can make any class object multiple times without calling its default constructor....

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