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

Java String Concatenation | Java Concat Method

String Concatenation in Java In general, Java does not allow operators to be applied to string objects except + operator which concatenates multiple strings and forms a new string. A string in Java can be concatenated with two or more strings or a string with a number or symbol to … 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

String in Java | String Literal, Constant Pool

A string is a very important topic in the world of programming languages. In almost all the programming languages such as C, C++, Java, Python, or in any application whether it is Java-based or Python-based, the most commonly used object is a string only. For example, when you visit a … Read more