Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to make a class immutable?

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


Please Help Members By Posting Answers For Below Questions

Why can't we use static class instead of singleton?

936


What about interrupt() method of thread class ?

1067


Which data type is class in java?

1008


What variables are stored in stack?

960


When we should use serialization?

1019


What is the java reflection api? Why it’s so important to have?

977


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

2596


What is the use of set in java?

1120


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

984


Why java uses the concept of the string literal?

1051


Can we convert stringbuffer to string?

1005


What is formatted output in java?

960


What if I write static public void instead of public static void in java?

1087


What does a za z0 9 mean?

1098


What is the default size of arraylist in java?

1117