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 class allows you to read objects directly from a stream?
Difference between current previous versions of Java?
Is java a compiler?
What is the use of java?
What is the benefit of inner classes in java?
What are the application of stack?
Why constructor has no return type?
What is the benefit of inner / nested classes ?
Does java allow overriding static methods ?
What is the memory leak in java?
What is an anonymous class in java?
What is meant by tab pans?
What is data type in java?
What are the common uses of "this" keyword in java ?
How do you pass by reference?