String Handling in Java

String Handling in Java | In String Handling, You will learn to store string data in JVM from a program & further perform several operations on this string data. The operations such as comparing, concatenating, replacing, changing cases, trimming, retrieving characters, splitting, e.t.c. operations.

Performing different operations on string data is called string handling. To perform several operations on string data there are many built-in methods are given in the String, StringBuffer, and StringBuilder classes. This article contains all the links to posts related to Java String.

Java String Tutorial

In Java, for String Handling, we mainly used the String, StringBuilder, and StringBuffer classes. The java.lang.String is an immutable class and it means once a string object is declared we can’t modify them, and on every modification, it creates a new string object. Whereas the StringBuilder and StringBuffer classes are mutable classes and they allow modification on the same object.

Java String Class & Methods

String Class Methods in Java:- charAt(), codePoints(), codePointAt(), codePointBefore(), codePointCount(), offsetByCodePoints(), compareTo(), compareToIgnoreCase(), concat(), contains(), equals(), equalsIgnoreCase(), format(), getBytes(), hashCode(), indent(), indexOf(), intern(), isBlank(), isEmpty(), join(), lastIndexOf(), length(), matches(), repeat(), replace(), replaceAll(), replaceFirst(), split(), startsWith() & endsWith(), strip() stripLeading() & stripTrailing(), substring(), toCharArray(), toLowerCase(), toString(), toUpperCase(), trim(), valueOf()

Java StringBuilder and StringBuffer Class

StringUtils Class

Apart from the String, StringBuilder, and StringBuffer class sometimes we need to use external libraries for String handling. One of the biggest limitations of String, StringBuilder, and StringBuffer class methods is that it doesn’t handle null properly, If an object is referencing to null then those methods will give NullPointerException.

To solve this problem and for other features, we can take the help of the Apache Common Lang package. This package contains StringUtils class having several methods for String handling.

  1. Import StringUtils in Java
  2. StringUtils Class Methods:-  isEmpty()isNotEmpty()isBlank()isNotBlank()isEmpty() vs isBlank()equals()lowerCase()isNumeric()rightPad()

Java String Programs

  1. Take String Input In Java using Scanner Class
  2. How to Find Length of String in Java
  3. How to Iterate through String Java
  4. Sum of digits in a String
  5. Count No of Vowels String
  1. String Pattern Programs in Java
  2. How To Reverse a String In Java
  3. String Palindrome In Java
  4. Sort String In Java
  5. How to Compare Strings In Java
  1. Check If String Contains Uppercase & Lowercase
  2. Java Check If Char is Uppercase
  3. Check If String is Uppercase Java
  4. Swap Characters in String Java
  5. Generate Random Strings
  1. Java Program to Find Weight of String
  2. Find Second Occurrence of Character in String Java
  3. Find Last Occurrence of Character in String Java
  4. Java Replace nth Occurrence String
  5. Replace Last Occurrence of Character in String Java
  1. How to Replace Dot in Java
  2. How To Remove Substring From String Java
  3. Replace Special Characters In Java
  4. Java Replace String With Escape Character
  5. Java Remove Special Characters From String
  1. How To Remove Character From a String Java
  2. Remove Commas From String Java
  3. Replace Comma in String Java
  4. Golden Ratio Java Program

Number programs using String

  1. Unique Number
  2. Fascinating Number
  3. ISBN Number

String Array Programs

  1. Java Convert Number String to Array
  2. How to Iterate Through a String Array In Java?
  3. Convert String Array to Lowercase Java
  4. String Array to UpperCase Java

Others/Games Programs using String

  1. Hidden Word Java Program
  2. Java Secret Message Program

Leave a Comment

Your email address will not be published. Required fields are marked *