Immutable object on Java

Yup yup yup, after the CNY passed. Job seeking resume, as expected that it’s really hard to find a entry lv Java job especially when no any prior experience. But today is more about Java.

While starting the journey of organising previous code. Found out that I wrote a small segment of Java code which kind of explain how immutable object work under the context of Java. As always code is available on my Github and link attached as below.

Principle of a immutable object.

First of all, all field on the object need to be “final”. Which mean field not allow further edit after construction. So technically speaking, the only chance of modifying object state is on construction.

All attribute need to be final


Constructer should be the only place to alter object’s state.


So by following the principle, in most of the use case only getter should be deploy instead of setter.


But how does it really come into kick on real-world application?  Dun got to know till get a Job to experience ne.  Keep tune of the Blog, reckon I would update more frequent as I am unemployed atm (Laugh).



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s