Java example - convert string from lower case to upper case


Java 实例 Java Example

The following example uses the String toUpperCase() method to convert a string from lower case to upper case:

//StringToUpperCaseEmp.java 文件

public class StringToUpperCaseEmp {
   public static void main(String[] args) {
      String str = "string abc touppercase ";
      String strUpper = str.toUpperCase();
      System.out.println("Original String: " + str);
      System.out.println("String changed to upper case: "
      + strUpper);
   }
}

The output result of the above code example is:

Original String: string abc touppercase 
String changed to upper case: STRING ABC TOUPPERCASE 

Java 实例 Java Example