Subscribe to Java/SCJP        RSS Feed
-----

Immutable classes

Icon Leave Comment
The objects which will not be changed too frequently then simply accessed should be made immutable. Though some utility functions can be provided to make changes. But the attributes should not be changed by the programmer once it has been set by the constructor.
To make a class' objects immutable, don't provide any setter methods.
A simple example is the String class of java API.

0 Comments On This Entry

 

January 2022

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
3031     

Recent Entries

Recent Comments

Search My Blog

12 user(s) viewing

12 Guests
0 member(s)
0 anonymous member(s)