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

1.Mark the class as final to avoid subclass, So subclass
can't change any thing in super class.
2. When ever you are chaning any property of that class
make a new instance of that calss.
e.g public modify(Object obj0)
{
ClassName a =new ClassName ();
a.modify()// modification logioc
}

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is floor in java?

1042


Is alive method in java?

986


Which number is denoted by leading zero in java?

1244


How can you generate random numbers in java?

1050


What is formatted output?

963


Is arraylist zero based?

1075


What is enhanced loop in java?

994


How do you do exponents in java?

1063


How to sort an array from smallest to largest java?

991


Is it possible to specify multiple jndi names when deploying an ejb?

999


How do you sort in descending order in java using collections sort?

899


What is java util concurrentmodificationexception?

919


What is the reason behind using constructors and destructors?

1066


What is a platform?

1081


Which graphs are functions?

976