1. A POJO is a method with private Instance Variables with Getter and Setter .
2 .. Classes of type String class that require the behavior/implementation constant in should be final all the time , and not the one that needs to change over time.
3. In order to make a class immutable, the final one is not only a solution , you can have private Instance Variables , only Getter methods . And their status is set to Constructor .
4. Now, depending on your decision on coding, try to fix which fields should be constant throughout the program , if you think certain fields should be immutable , make them final.
5. The JVM uses the Constant folding mechanism to pre-calculate constant values.
source share