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 is Major and importance difference between for and foreach loop ?

1139


What is the abstract class?

1022


What is garbage collection? Can it be forced to run?

1004


Can a class have more than one object?

992


What is the purpose of stub and skeleton?

1027


What is string in java with example?

1016


Is empty set an element of empty set?

1101


Is Constructor possible in abstract class in java ?

1056


Can one thread block the other thread?

1025


What is immutable state?

1016


State the difference between strings and arrays.

1233


What do you mean by multithreaded program?

1007


What are the properties of thread?

924


Difference between arraylist and hashset in java?

1126


If a variable is declared as private, where may the variable be accessed?

1052