Java String toUpperCase() method is used to convert a String into uppercase. All characters of a String are converted into uppercase characters.

There are two variants of toLowerCase() method:

I.) String java.lang.String.toUpperCase()

This method coverts a String into uppercase according to default locale which is en_IN.

II.) String java.lang.String.toUpperCase(Locale locale)

This method coverts a String into uppercase according to the rules of the locale which is passes as an argument in the method.

Let’s take an example to illustrate toUpperCase() method.

Example : Java String toUpperCase() Method

package com.masterjavatutorial;
import java.util.Locale;
public class Test {
	public static void main(String[] args) {
		String str = "This Is demo for uppercase method";
		String uppercase  = str.toUpperCase(); 
		System.out.println(uppercase);
		
		Locale locale = Locale.FRANCE; 
		String uppercase1 = str.toUpperCase(locale);
		System.out.println(uppercase1); 
	}
}

Output of the above program is as below:

THIS IS DEMO FOR UPPERCASE METHOD
THIS IS DEMO FOR UPPERCASE METHOD

In this output is same for both variants of toUpperCase() method but it can differ in other cases.