Making a Java String All Uppercase or All Lowercase.

Java 8Object Oriented ProgrammingProgramming

The toUpperCase() method converts all of the characters in this String to upper case using the rules of the default locale

The toLowerCase() method converts all of the characters in this String to lower case using the rules of the default locale.

Example

Live Demo

import java.lang.*;

public class StringDemo {
   public static void main(String[] args) {
      // converts all upper case letters in to lower case letters
      String str1 = "SELF LEARNING CENTER";
      System.out.println("string value = " + str1.toLowerCase());

      str1 = "TUTORIALS POINT";
      System.out.println("string value = " + str1.toLowerCase());

      // converts all lower case letters in to upper case letters
      String str2 = "This is TutorialsPoint";

      System.out.println("string value = " + str2.toUpperCase());
      str2 = "www.tutorialspoint.com";
      System.out.println("string value = " + str2.toUpperCase());
   }
}

Output

string value = self learning centre
string value = tutorials point
string value = THIS IS TUTORIALSPOINT
string value = WWW.TUTORIALSPOINT.COM
raja
Published on 12-Feb-2018 14:11:09
Advertisements