toLowerCase() String Example

java.lang.String class comes with toLowerCase() String method to convert all uppercase letters into lowercase in the string. After modification, a new string is returned with all the conversions.

The signature of toLowerCase() String is given as defined in Java API.

  • public String toLowerCase(): Returns a new string after converting all the uppercase letters to lowercase letters in the given string.

In the following example, toLowerCase() String is used to convert all uppercase letters to lowercase letters in string oldString. Original string oldString is not disturbed.

public class StringMethodDemo
 public static void main(String args[])
  String oldString = "Hello World How Do You Do";

  String newString = oldString.toLowerCase();

  System.out.println("Original string before conversion: " + oldString);
  System.out.println("\nNew string after conversion: " + newString);

toLowerCase() String
Output screen of toLowerCase() String Example

Pass your comments and suggestions on this tutorial "toLowerCase() String Example".

Leave a Comment

Your email address will not be published.