answersLogoWhite

0

What is immutable means in java?

User Avatar

Anonymous

16y ago
Updated: 8/17/2019

immutable means we can't change the content of string object Example:

String name = "Tommy"; String fullName = name + "Junior";

Here when we declared fullName you would expect it to be appended to the system memory location where the variable name is saved. But in Java it does not happen this way.

Here a new variable fullName would be created in memory and the value would be saved there.

This is termed as immutable. i.e., String objects cannot be modified in memory once they are created. You may be able to view the change in your program but new String objects would be created in the system memory.

Tip:

If you want to modify your String objects, then it is advisable to use a StringBuffer instead of a String. StringBuffer allows us to modify string objects and they would be saved in only one place in the system memory. Hence the memory utilization of the system would be much better than the normal String.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What is mutable in java?

It means that something can be changed after it is created. Immutable means that it can't be changed.


What mutable and immutable in java and example program?

lmutable object


How to create immutable class in java?

by making that class final


Where can one watch immutable objects?

An immutable object is classed in Java programming as an object that cannot be changed after it is made. YouTube has videos that can be viewed on this subject as well as Vimeo.


Which classes are mutable and nonmutable?

An immutable class is any data storage class in which the data cannot be changed. The most common example of this in Java is the String class.


What is the root word of immutable?

The root word of immutable is "mutable," which means capable of being changed or altered. Adding the prefix "im-" changes the meaning to "not capable of being changed."


What is string buffer in java?

StringBuffer is java class available in java.lang package which provides mutable String object where String is immutable class. The methods of this class like reverse(), append(),insert() gives facility to insert data of the same object.


What is a sentence for the word immutable?

There are certain immutable truths in life.


Are strings immutable in C?

Yes, strings are immutable in C. This means that once a string is created, its contents cannot be changed. If you need to modify a string, you would need to create a new string with the desired changes.


What does the word java mean?

Java is an island in Indonesia, but in slang it means coffee.


When was Play the Immutable Truth created?

Play the Immutable Truth was created in 2004.


Are Wrapper classes immutable or mutable?

In java.lang all Wrapper classes are immutable .