Java toUpperCase() 方法

toUpperCase() 方法用于将小写字符转换为大写。

语法

  1. char toUpperCase(char ch)

参数

  • ch — 要转换的字符。

返回值

返回转换后字符的大写形式,如果有的话;否则返回字符本身。

实例

  1. public class Test {
  2. public static void main(String args[]) {
  3. System.out.println(Character.toUpperCase('a'));
  4. System.out.println(Character.toUpperCase('A'));
  5. }
  6. }

以上程序执行结果为:

  1. A
  2. A