Java String.toUpperCase() Method Example

There are two forms of String.toUpperCase() methods.
  • toUpperCase()  - Converts all of the characters in this String to upper case using the rules of the default locale.
  • String toUpperCase(Locale locale)  - Converts all of the characters in this String to upper case using the rules of the given Locale.

Java String.toUpperCase() Method Example

This is a complete example to demonstrate the usage of both toUpperCase() methods.
public class ToUpperCaseExample {
    public static void main(String[] args) {
        String str = "javaguides";
        String subStr = str.toUpperCase();
        System.out.println(subStr);
        subStr = str.toUpperCase(Locale.ENGLISH);
        System.out.println(subStr);
    }
}

Output:
JAVAGUIDES JAVAGUIDES 

Reference


Comments