View Diksha  Basu 's Profile
What is immutable object in Java? Can you change values of a immutable object?
Hi All, Please provide the answers in descriptive manner.
Asked by Diksha Basu | Aug 10 2018 | Report this Report abuse
Replies (10)
View Tanya  Sharma 's Profile
Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process
Aug 18 2018 | Report this Report abuse
View Nirupama  Pathak 's Profile
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed & reused
Aug 18 2018 | Report this Report abuse
View Shuchita   Shukla 's Profile
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed & reused
Aug 18 2018 | Report this Report abuse
View Roshan  shah 's Profile
Hai, Here I found Nice Youtube tutorial about this thread from NareshIT Very good explanation So lets check it


What is immutable object in Java?: https://youtu.be/6oHdtXEkKKk
http://nareshit.com/
Aug 17 2018 | Report this Report abuse
View Shatish  Rao 's Profile
Hai, Here I found Nice Youtube tutorial about this thread from NareshIT Very good explanation So lets check it


What is immutable object in Java?: https://youtu.be/6oHdtXEkKKk
http://nareshit.com/
Aug 17 2018 | Report this Report abuse
View Nirupama  Pathak 's Profile
In java unused components are cleares by Garbage collector.
Whenever cpu gets the free time then it calls the 'gc()' method to do this task.
We can do it manually by calling gc() method explicitly.
Aug 17 2018 | Report this Report abuse
View Chinmay  Hegde 's Profile
In java unused components are cleares by Garbage collector.
Whenever cpu gets the free time then it calls the 'gc()' method to do this task.
We can do it manually by calling gc() method explicitly.
Aug 17 2018 | Report this Report abuse
View Roshan  shah 's Profile
I have shared few thoughts on creating Immutable classes at my blog http://javarevisited.blogspot.sg/2013/03/how-to-create-immutable-class-object-java-example-tutorial.html, you may find useful. Thanks
Aug 17 2018 | Report this Report abuse
View Shuchita   Shukla 's Profile
I have shared few thoughts on creating Immutable classes at my blog http://javarevisited.blogspot.sg/2013/03/how-to-create-immutable-class-object-java-example-tutorial.html, you may find useful. Thanks
Aug 17 2018 | Report this Report abuse
View Tanya  Sharma 's Profile
A Java object is considered immutable when its state cannot change after it is created. Use of immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state. java.lang.String and java.lang.Integer classes are the Examples of immutable objects from the Java Development Kit. Immutable objects simplify your program, since they :

are simple to use test and construct.
are automatically thread-safe.
do not require a copy constructor.
do not require an implementation of clone.
allow hashCode to use lazy initialization, and to cache its return value.
do not need to be copied defensively when used as a field.
are good Map keys and Set elements (these objects must not change state while stored in the collection).
have their class invariant established once upon construction, and it never needs to be checked again.
always have "failure atomicity" (a term used by Joshua Bloch) : if an immutable object throws an exception, it's never left in an undesirable or indeterminate state.
Aug 16 2018 | Report this Report abuse