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

Can It is possible to synchronize the constructor of a Java Class?

1119


What are the different ways of implementing thread? Which one is more advantageous?

979


How does callback work in java?

1060


What is the return type of the main method?

1033


What is the difference between preparedstatement and statement in java?

1145


What are the principle concepts of oops?

955


What is regex in java?

945


What if static is removed from main method?

1068


Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?

1128


What is the difference between the ">>" and " >>>" operators in java?

983


How do you write methodology?

984


Can we sort set in java?

950


What are the differences between path and classpath variables?

1040


What is a priority queue java?

985


What is bubble sorting in java?

1040