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

While creating class objects of which will be immutable. The following
things should be kept in mind:
1. Class should be made final so that no class can extend it.
2. Access modifiers of the instance variables must be private so that no
object can have access to it.
3. There should not be any public set method which can change the state of
the object.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you remove an object from an arraylist in java?

903


What is the importance of static variable?

1052


what is meant by Byte code concept in Java?

1005


What is a constructor, constructor overloading in java?

958


Differentiate between stringbuffer and string?

989


What initialize variables?

947


What is the difference between state-based unit testing and interaction-based unit testing?

882


What is the most important feature of java? What is an interface?

952


What comes to mind when someone mentions a shallow copy in java?

1061


What is finally in Java?

1011


Which sorting is best in java?

957


Is void a data type in java?

920


Is there is any difference between a scrollbar and a scrollpane?

938


What is string builder in java?

949


What is the use of predicate in java 8?

890