Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Why String is immutable or final in Java

Category: Java
  • There are several benefits of String because it’s immutable and final. String Pool is possible because String is immutable in java.
  • It increases security because any hacker can’t change its value and it’s used for storing sensitive information such as database username, password etc.
  • Since String is immutable, it’s safe to use in multi-threading and we don’t need any synchronization.
  • Strings are used in java classloader and immutability provides security that correct class is getting loaded by Classloader.

Leave a Reply

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