Skip to Content

Java String to Lower Case example

  1. /*
  2.         Java String to Lower Case example.
  3.         This Java String to Lower Case example shows how to change the string to lower case
  4.         using toLowerCase method of String class.
  5. */
  6.  
  7. public class StringToLowerCaseExample {
  8.  
  9.         public static void main(String[] args) {
  10.                
  11.                 String str = "STRING TOLOWERCASE EXAMPLE";
  12.                
  13.                 /*
  14.                  * To change the case of string to lower case use,
  15.                  * public String toLowerCase() method of String class.
  16.                  *
  17.                  */
  18.                  
  19.                  String strLower = str.toLowerCase();
  20.                  
  21.                  System.out.println("Original String: " + str);
  22.                  System.out.println("String changed to lower case: " + strLower);
  23.         }
  24. }
  25.  
  26. /*
  27. Output would be
  28. Original String: STRING TOLOWERCASE EXAMPLE
  29. String changed to lower case: string tolowercase example
  30. */