Understanding String and StringBuilder Class in Java

String

The string is the most widely used class in Java Language. One of the important features of String Class is it is immutable. This means once the String object is created, it can never be modified. The main advantage of this feature is it helps to reduced memory overhead and increase performance.

StringBuilder

In contrast to the String class, the StringBuilder class is immutable. It is usually used when the strings are larger and we have to modify the content quite often. StringBuilder class inherits from its superclass AbstractStringBuilder. Here is a partial definition of the class.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store