Java string case change sample code examples.


You can change the cases using the toUpperCase() and toLowerCase() methods of the String class.

Example

Live Demo

public class Sample {
   public static void main(String args[]){
      String str = "Hello how are you";
      String strUpper = str.toUpperCase();
      System.out.println("Lower to upper : "+strUpper);
      String strLower = str.toLowerCase();
      System.out.println("Upper to lower : "+strLower);
   }
}

Output

Lower to upper : HELLO HOW ARE YOU
Upper to lower : hello how are you


Updated on: 26-Feb-2020

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements