Question
Why Strings in Java are called as Immutable?

Answers

In java, string objects are called immutable as once value has been assigned to a string, it can’t be changed and if changed, a new object is created.
In below example, reference str refers to a string object having value “Value one”.
Java
String str="Value One"; 1
String str="Value One";

 
When a new value is assigned to it, a new String object gets created and the reference is moved to the new object.
Java
str="New Value"; 1
str="New Value";

    Your Comment




More Software,Java Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q Yukio Hatoyama was sworn in as the sixtieth prime minister of which country?
  • Q What are the different career options you have?
  • Q What is the typical shape of a population growth curve? How can the biotic potential be represented in the same way graphically?
  • Q Who was the first Chairman of the Planning Commission?
  • Q Mention how connectors work in OWB?
  • Q What are the different tables used in EIGRP?
  • Q What is ioc?
  • Q What elements make up the personnel structure?
  • Q Explain my string data is all coming out as question marks?
  • Q What is a task?
  • Q What is difference between (=) and (==) method?