Convert String object to lower case & upper case in java (example)

  • Given a String in java, we would like to convert the input String to lower case & upper case.
  • String class has couple of methods, to convert input string to lower case & upper case.
No.Method Name Description
1toLowerCase toLowerCase method will convert the input String to lower case.
2toUpperCase toUpperCase method will convert the input String to upper case.

1. Program – convert input string to lower case & upper case in java.

package org.learn;

public class ChangeStringCase {
    public static void main(String[] args) {
        String inputString = "Example of string case";

        String upperCase = inputString.toUpperCase();
        String lowerCase = inputString.toLowerCase();

        System.out.println("1. Input string is :"+inputString);
        System.out.println("2. Lower case string is :"+lowerCase);
        System.out.println("3. Upper case string is :"+upperCase);
    }
}

2. Output – convert input string to lower case & upper case in java.

1. Input string is :Example of string case
2. Lower case string is :example of string case
3. Upper case string is :EXAMPLE OF STRING CASE
Scroll to Top