Java String Tutorial

A string is the most important topic in all topics of Java. It is also a favorite topic for any interviewer. Whenever you will go for any technical interview, the interviewer always asks questions from string concepts. Here, you will get Java String tutorials with the best example programs and … Read more

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

StringBuffer Class in Java | Example Programs

StringBuffer Class in Java You have learned in the previous tutorial that string is fixed-length, immutable and cannot be modified. i.e, Once we create a String object, we cannot change its content. To overcome this, we got another class StringBuffer. It is also present in the java.lang package similar to the string class. 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