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 the major difference between linkedlist and arraylist?
What happens if an exception is not handled in a program?
What is the difference between a field variable and a local variable?
What is javac_g?
explain the concept of virtual method invocation in polymorphism in detail?
What are the differences between c++ and java?
What is parsing a sentence?
Can we override the overloaded method?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
Is singleton class thread safe?
What is the size of int in 64-bit jvm?
What is a java developer salary?
How many types of threads are there in java?
What is the definition of tree ?