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 balanced tree in java?
Explain about main thread in java?
Explain illegalmonitorstateexception and when it will be thrown?
What is a class instance variable?
What is the static keyword?
Explain tree set and its features?
What is the difference between arraylist and hashset in java?
What language is an assembler written in?
What does string [] args mean?
What is methodological theory?
Explain yield() method in thread class ?
What are the object and class classes used for?
How to perform linear search in java?
I don’t want my class to be inherited by any other class. What should I do?
what is the swingutilities.invokelater(runnable) method for? : Java thread