Java.lang.Character.toUpperCase() 方法
描述
java.lang.Character.toUpperCase(int codePoint) 使用 UnicodeData 文件中的大小写映射信息将字符(Unicode 代码点)参数转换为大写。
请注意,Character.isUpperCase(Character.toUpperCase(codePoint)) 并不总是对某些字符范围返回 true,尤其是符号或表意文字。
声明
以下是 java.lang.Character.toUpperCase() 方法的声明。
public static int toUpperCase(int codePoint)
参数
codePoint − 要转换的字符(Unicode 代码点)
返回值
此方法返回字符的大写等效项(如果有); 否则,就是本身。
异常
NA
示例
下面的例子展示了 lang.Character.toUpperCase() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class CharacterDemo {
public static void main(String[] args) {
// create 4 int primitives
int cp1, cp2, cp3, cp4;
// assign values to cp1, cp2
cp1 = 0x0072; // represents r
cp2 = 0x0569; // represents ARMENIAN SMALL LETTER TO
// assign uppercase of cp1, cp2 to cp3, cp4
cp3 = Character.toUpperCase(cp1);
cp4 = Character.toUpperCase(cp2);
String str1 = "Uppercase equivalent of " + cp1 + " is " + cp3;
String str2 = "Uppercase equivalent of " + cp2 + " is " + cp4;
// print cp3, cp4 values
System.out.println( str1 );
System.out.println( str2 );
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Uppercase equivalent of 114 is 82 Uppercase equivalent of 1385 is 1337

