Java Example To Convert String To Uppercase And Lowercase

Sharing is healthy !!

Hey guys!! How are you doing. Today we are going to learn java example to convert string to uppercase and lowercase.

Not something you do everyday. But occasionally when you are manipulating input from a user you will need to do that.

These methods that I will talk about here will show you how to set that up.

Well, converting java string from uppercase to lowercase is very straight forward. In java we have two inbuilt methods and they are,

  • toLowerCase()
  • toUpperCase()

Let’s see the code implementation,

Also Read – Convert Date To String Java Program

public class StringChangeCase
{
   public static void main(String[] args)
   {
      String strConvert = "Great Barrier Reef";
 
      String convertLower = strConvert.toLowerCase();
      String convertUpper = strConvert.toUpperCase();
 
      System.out.println("Before conversion - " + strConvert);
      System.out.println("\nAfter conversion - \n");
      System.out.println("To Lowercase - " + convertLower);
      System.out.println("To Uppercase - " + convertUpper);
   }
}

Output:

Java Example To Convert String To Uppercase And Lowercase

Sharing is healthy !!

You May Also Like