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 / 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


Please Help Members By Posting Answers For Below Questions

What class allows you to read objects directly from a stream?

1320


Difference between current previous versions of Java?

1019


Is java a compiler?

976


What is the use of java?

959


What is the benefit of inner classes in java?

1085


What are the application of stack?

918


Why constructor has no return type?

1099


What is the benefit of inner / nested classes ?

988


Does java allow overriding static methods ?

1112


What is the memory leak in java?

1034


What is an anonymous class in java?

1100


What is meant by tab pans?

1235


What is data type in java?

902


What are the common uses of "this" keyword in java ?

1021


How do you pass by reference?

1054