Showing posts with label Immutable. Show all posts
Showing posts with label Immutable. Show all posts

Tuesday, April 7, 2020

How to Create An Immutable Class in java?

1. Immutable Class in Java


This is a common nterview question for 2-4 years java experienced developer. In this tutorial, We'll learn "How to Create Immutable Class in java?" You'll learn why we need to create Immutable class and what are the advantages and as well the disadvantages of it.

Immutable class means it cannot be modified once it is created. If any modification on an immutable object then the result will give another immutable object.

How to Create An Immutable Class in java?

Builtin API immutable classes:

String, StringBuffer, and all wrapper classes, etc.