Java string case change sample code examples.

Java 8Object Oriented ProgrammingProgramming

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


raja
Published on 12-Feb-2018 12:59:18
Advertisements