Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

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: 2020-02-26T09:49:50+05:30

134 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements