如何在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
热门推荐
10 送师姐的祝福语简短
11 哥哥祝福语简短霸气句子
12 分手快乐祝福语简短
13 住学长学姐祝福语简短
14 保持快乐祝福语大全简短
15 生日哥哥祝福语简短独特
16 兄弟的结婚祝福语简短
17 亲姐姐怀孕祝福语简短
18 给医生简短新年祝福语