Java String Concatenation: Why Strings Are Immutable

This looks simple… but confused me at first 😅 String str = "Java"; str.concat(" Developer"); System.out.println(str); 👉 Output: Java ❌ (not "Java Developer") Why? Because String is immutable in Java. 👉 concat() creates a new object 👉 original string remains unchanged ✅ Correct way: str = str.concat(" Developer"); 💡 Small concept, but very important in real projects. Did you know this? 👇 #Java #CoreJava #Programming #BackendDeveloper #Coding #TechLearning

Despite of being java developer, you are realising things very late bro 😁

Like
Reply

Help to know other if some one dont know this tq i know but .if someone post something then people start assuming based on post that is not good

See more comments

To view or add a comment, sign in

Explore content categories