String Constructor in Java with Example

String Class Constructor in Java The string class supports several types of constructors in Java APIs. The most commonly used constructors of String class are as follows: 1. String(): To create an empty String, we will call a default constructor. For example:          String s = new String();  It … Read more

Substring in Java | Example Programs

Java Substring Substring in Java is a subset of the main string specified by start and end indices. We can extract a substring using substring() method. String class provides two forms of substring methods. 1. public String substring(int startIndex): This method returns a new string that is a substring of this string. … Read more

Immutable String in Java | Immutable Object

Why String is Immutable in Java? String class in Java is immutable. The meaning of immutable is unchangeable or unmodifiable. i.e. Once we create a string object with value, you are not allowed to perform any changes in that object. In other words, you cannot modify the value of the string. … Read more