---
title: "Why string objects are immutable in java?"  
description: "Why string objects are immutable in java?"  
author: "Anonymous User"  
published: 2015-04-25  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/2435/why-string-objects-are-immutable-in-java  
category: "java"  
tags: ["java", "string"]  
reading_time: 1 minute  

---

# Why string objects are immutable in java?

Because java uses the concept of string literal. Suppose there are 5 reference variables,all referes to one object "sachin".If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.

## Answers

### Answer by Anonymous User

Because java uses the concept of string literal. Suppose there are 5 reference variables,all referes to one object "sachin".If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.


---

Original Source: https://www.mindstick.com/interview/2435/why-string-objects-are-immutable-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
