String, StringBuilder and StringBuffer in Java

Serxan Hamzayev
2 min readJan 14, 2023

A String in Java is an immutable sequence of characters, meaning that once it is created, its value cannot be modified.

For example:

String str = "Hello";
str = str + " World";

In the example above, a new String object is created with the value “Hello World” and the reference str is pointing to the new object, the old one with…

--

--