如何在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 婆婆高寿祝福语大全简短