How to Change String to Uppercase in Java


In this example we will show how to change the string to uppercase with toUpperCase method of String class.

Source Code

package com.beginner.examples;

public class StringToUpperCase {

	public static void main(String[] args) {
		
		//Create String.
		String string = "Hello World";
		
		/*
		 * To change the case of string to upper case use toUpperCase() method of Java String.
		 */
		String result = string.toUpperCase();
		
		System.out.println(result);

	}

}

Output:

HELLO WORLD
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments