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

Can we override the static method?

1030


What are the steps involved to create a bean?

1159


How to convert string to byte array and vice versa?

1090


What is the difference between error and an exception?

1157


What is finalize() function in java?

1020


What is the difference between class & structure?

1230


What is indexof?

987


What is a Transient Object?

1085


What is the difference between JDK and JVM?

1272


what are the high-level thread states? : Java thread

1024


Why arraylist is not synchronized in java example?

1070


What is string pool?

1129


How do you change an int to a string?

1013


What is meant by inheritance and what are its advantages?

1109


What are default methods ?

1048