如何在Java中查找给定字符的unicode类别?
甲字符 类是一个的子类对象 ,并将其在对象包装基本类型char的值。类型为Character的对象包含一个类型为char的单个字段。我们可以使用getType()方法确定特定字符的unicode类别。这是Character 类的静态方法,它返回以unicode通用类别表示的charch 的整 数值。
语法
public static int getType(char ch)
示例
public class CharacterTypeTest {
public static void main(String args[]) {
System.out.println("T represnts unicode category of: " + Character.getType('T'));
System.out.println("@ represnts unicode category of: " + Character.getType('@'));
System.out.println(") represnts unicode category of: " + Character.getType(')'));
System.out.println("1 represnts unicode category of: " + Character.getType('1'));
System.out.println("- represnts unicode category of: " + Character.getType('-'));
System.out.println("_ represnts unicode category of: " + Character.getType('_'));
System.out.println("a represnts unicode category of: " + Character.getType('a'));
}
}输出结果
T represnts unicode category of: 1 @ represnts unicode category of: 24 ) represnts unicode category of: 22 1 represnts unicode category of: 9 - represnts unicode category of: 20 _ represnts unicode category of: 23 a represnts unicode category of: 2
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿