---
title: "Comment by Shai Almog on \"Why Strings are immutable in Java?\" | Hashnode"
description: "Great post! Also I think the reason is to make it a bit more consistent with the behavior of the primitive types. I would also add that the JVM can then do some"
url: "https://hashnode.com/posts/why-strings-are-immutable-in-java/62aec7a30924134a80488f8e/comment/62aeea490924134a804892ef"
---

[Discussion](https://hashnode.com/posts/why-strings-are-immutable-in-java/62aec7a30924134a80488f8e)

Comment [Why Strings are immutable in Java?](https://hashnode.com/posts/why-strings-are-immutable-in-java/62aec7a30924134a80488f8e)

[Shai Almog](https://hashnode.com/@talktotheduck)

[Jun 19, 2022](https://hashnode.com/posts/why-strings-are-immutable-in-java/62aec7a30924134a80488f8e/comment/62aeea490924134a804892ef)

Great post!

Also I think the reason is to make it a bit more consistent with the behavior of the primitive types.

I would also add that the JVM can then do some [pretty cool optimizations](https://www.baeldung.com/java-9-compact-string) to Strings seamlessly thanks to that...

[Shashank Bhat G S](https://hashnode.com/@shashankbhatgs)

[Jun 22, 2022](https://hashnode.com/posts/why-strings-are-immutable-in-java/62aec7a30924134a80488f8e/comment/62aeea490924134a804892ef#reply-62b353c386d22092a7546d0d)

Thanks for the point
