Answer Posted / tapan k dinda
To make class immutable you need to follow steps below:-
1. class should be final(strong Immutability) or all
methods final(weak Immutability)
2. all fields should be private
3. no setter/mutator should be provided
4. make deep copies of mutable data, if any
any confusion plz mention in your next post.
| Is This Answer Correct ? | 10 Yes | 2 No |
Post New Answer View All Answers
What is Major and importance difference between for and foreach loop ?
What is the abstract class?
What is garbage collection? Can it be forced to run?
Can a class have more than one object?
What is the purpose of stub and skeleton?
What is string in java with example?
Is empty set an element of empty set?
Is Constructor possible in abstract class in java ?
Can one thread block the other thread?
What is immutable state?
State the difference between strings and arrays.
What do you mean by multithreaded program?
What are the properties of thread?
Difference between arraylist and hashset in java?
If a variable is declared as private, where may the variable be accessed?