Convert string to uppercase in Java

Following example changes the case of a string to upper case by using String toUpperCase() method.
Code snippet

public class StringToUpperCase {
   public static void main(String[] args) {
      String str = "java programming ";
      String strUpper = str.toUpperCase();
      System.out.println("Original String: " + str);
      System.out.println("String changed to upper case: "
      + strUpper);
   }
}
Output
The above code sample will produce the following result.
Original String: java programming
String changed to upper case: JAVA PROGRAMMING


Source code: