Write a program to convert all the characters in a string to Uppercase


This Java program converts a given String to uppercase using the toUpperCase() method and prints the resulting uppercase String.

  • The program defines a public class named "UpperCase" with a main method that takes no arguments. The main method declares a String variable str with the value "Tutor Joes Computer Education".
  • Then, the program uses the toUpperCase() method of the String class to convert str to uppercase and stores the result in the String variable lwr_str.
  • Finally, the program prints out the original String str and the resulting uppercase String lwr_str using the System.out.println method.

Source Code

public class UpperCase
{
	public static void main(String[] args)
	{
		String str = "Tutor Joes Computer Education";
		String lwr_str = str.toUpperCase();
		System.out.println("Given String : " + str);
		System.out.println("String in Uppercase : " + lwr_str);
	}
}

Output

Given String : Tutor Joes Computer Education
String in Uppercase : TUTOR JOES COMPUTER EDUCATION

Example Programs