Answer Posted / rashmin
To make a class immutable follow the below steips
1. Make the class Final.
2. Make the instance variables private and final.
3. Make the methods in the class also final.
By doing the above 3 we can create a fully immutable class.
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
Why can't we use static class instead of singleton?
What about interrupt() method of thread class ?
Which data type is class in java?
What variables are stored in stack?
When we should use serialization?
What is the java reflection api? Why it’s so important to have?
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example
What is the use of set in java?
why are wait(), notify() and notifyall() methods defined in the object class? : Java thread
Why java uses the concept of the string literal?
Can we convert stringbuffer to string?
What is formatted output in java?
What if I write static public void instead of public static void in java?
What does a za z0 9 mean?
What is the default size of arraylist in java?