Category Java

StringBuffer Class in Java

Difference between length and capacity in Java StringBuffer class

StringBuffer in Java is a peer class of String that provides much of the functionality of strings. It provides more flexibility than String. As we know that a string is fixed-length, immutable, and cannot be modified. That is, once we…

Substring in Java (with Example)

Memory concept for allotting substring object.

Substring in Java is a subset of the main string specified by start and end indices. We can extract substrings by using substring() method. Consider the following example. String str = “Hello, World”; String sub = str.substring(0, 5); // sub…

String Concatenation in Java

String concatenation in Java

String concatenation in Java is the process of joining or combining two or more strings together to create a new string. It is one of the most common operation or task in any programming languages. For example, when you fill…

Immutable String in Java

Why string is immutable in Java

String class in Java is immutable. The meaning of immutable is unchangeable or unmodifiable. That is, once we create a string object with value, we are not allowed to perform any changes in that object. In other words, we cannot…

String in Java | String Literal, String Pool

Creating object to string class in Java is by using new operator

A string is a very important topic in the world of Java or any other programming languages. In almost all programming languages such as C, C++, Java, Python, or any application, whether Java-based or Python-based, the most commonly used object…