Way2Java

toUpperCase() String Example

java.lang.String class comes with toUpperCase() String method to convert all lowercase letters into uppercase in the string. After modification, a new string is returned with all the conversions.

The signature toUpperCase() String is given as defined in Java API.

In the following example, toUpperCase() String is used to convert all lowercase letters to uppercase letters in string oldString. Observe the screenshot, the original string oldString is not disturbed.

public class StringMethodDemo
{
 public static void main(String args[])
 {
  String oldString = "Hello World How Do You Do";

  String newString = oldString.toUpperCase();

  System.out.println("Original string before conversion: " + oldString);
  System.out.println("\nNew string after conversion: " + newString);
 }
}



Output screenshot of toUpperCase() String Example

Pass your comments and suggestions on this tutorial "toUpperCase() String Example".