Which classes in java are immutable ?

By | November 26, 2019

In this blog post we will talk and learn about one of very important java  interview question and question is that What are the classes in java are immutable ?

Classes in java are immutable

  • All wrapper classes are immutable –

Boolean , Character, Byte, Short, Integer,Long, Float, Double

  • Java.lang.String class is also Immutable
  • Immutable classes under java.math Package:

BigDecimal and BigInteger

  • java.lang.StackTraceElement (used in building exception stacktrace)
  • Most of classes under java.time package

You may also like:

Why Java is not 100% Object-oriented language?
What are the differences between 32-bit and 64-bit versions of Java?
Can we call static method with null object?
Can we override static method in Java?
What will be the output of following java program?
What is the difference Between java.util.Date and java.sql.Date in Java ?
What is difference between using Serializable & Externalizable Interfaces in Java?

Thanks for visiting our blog.
If you have any feedback or suggestion please feel free to drop in blow comment box. 

Leave a Reply

Your email address will not be published. Required fields are marked *