All Posts

Java toUpperCase() method

Java toUpperCase() method

The Java toUpperCase() method returns the string in uppercase letters. This method converts all characters of the string into upper-case letters

Example

Let’s understand the toUpperCase() method with an example as shown below:

package com.testingdocs.stringmethods;

public class ExampleProgram {

	public static void main(String[] args) {

		String str= "This is a Sample Sentence Example.";
		
		// toUpperCase() method demo
		System.out.println("Before           : " + str);
		System.out.println("After toUpperCase: " + str.toUpperCase());
	}
}

Program Output

The program produces the following output as shown below:

Before : This is a Sample Sentence Example.

After toUpperCase: THIS IS A SAMPLE SENTENCE EXAMPLE.

Java toUpperCase method

Java Tutorials

Java Tutorial on this website: