• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a class immutable  RSS feed

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you please answer the two questions?

1) How do I make a class immutable?
2) How I synchronize a map?

Thanks
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Padma priya Gururajan wrote:1) How do I make a class immutable?


You can probably find quite a few discussions on this if you search. But here's an alternative way of looking at it. How do you make a class mutable? After all, there's no mutable state in the Object class, so adding mutability is something you do to a class. Then you need to not do that.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Padma priya Gururajan wrote: . . . 2) How I synchronize a map?

Thanks
If you look in the documentation for HashMap, it tells you what to do.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!