0

How can I make a class immutable in java ;

Immutable

14th Jun 2017, 6:57 PM
BharatBhushan
BharatBhushan - avatar
4 Answers
+ 1
make it private and make it final and don't give any setters or getters
14th Jun 2017, 7:14 PM
SoakedInAllan
SoakedInAllan - avatar
+ 2
@Soaked The instance variables need a getter if its private. (If you want to be able to use them).
14th Jun 2017, 9:26 PM
Rrestoring faith
Rrestoring faith - avatar
0
you can break my answer down on Google of you need
14th Jun 2017, 7:15 PM
SoakedInAllan
SoakedInAllan - avatar
0
hmm.thankyou
14th Jun 2017, 7:16 PM
BharatBhushan
BharatBhushan - avatar