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 class immutable

Answer Posted / al rahid

1. Declare the Class as final (this inherently makes all
member function final)
2. Declare member variables private (not necessarily final,
because private instance variable are accessed via public
member functions only, e.g. in java.lang.String class,
variable "hash" is declared as "private int hash;" with no
final keyword).

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is jee6?

1084


How do you bind variables?

1078


A person says that he compiled a java class successfully without even having a main method in it? Is it possible?

1040


Write a method that will remove given character from the string?

1003


What is java Applet?

1086


What is google full form?

989


What about features of local inner class?

1051


What are thread groups?

988


Is singleton thread safe in java?

960


What is the Scope of Static Variable?

1213


What are the parts of methodology?

962


What are peerless components?

1069


How many bits is a char?

967


Are static members inherited to sub classes?

1123


Where is the find and replace?

992