java.lang.Character.isLetter(int codePoint)%uA0确定指定字符(Unicode代码点)是否为一个字母。
字符被确定是一个字母,如果一般性类别类型,通过getType(codePoint)所提供,是下列任何一项:
-
UPPERCASE_LETTER
-
LOWERCASE_LETTER
-
TITLECASE_LETTER
-
MODIFIER_LETTER
-
OTHER_LETTER
不是所有的字母都如此。许多字符是字母,但它们既不是大写,也不是小写,也没有首字母大写。
声明
以下是java.lang.Character.isLetter()方法的声明
public static boolean isLetter(int codePoint)
参数
-
codePoint%uA0- 字符(Unicode代码点)进行测试
返回值
如果字符是字母此方法返回true,否则返回false。
异常
-
NA
例子
下面的例子显示lang.Character.isLetter()方法的使用。
package com.yiibai import java.lang.* public class CharacterDemo { public static void main(String[] args) { // create 2 int primitives cp1, cp2 int cp1, cp2 // assign values to cp1, cp2 cp1 = 0x0065 cp2 = 0x007c // create 2 boolean primitives b1, b2 boolean b1, b2 // check if cp1, cp2 represent letter and assign results to b1, b2 b1 = Character.isLetter(cp1) b2 = Character.isLetter(cp2) String str1 = "Code point cp1 represents a letter is " + b1 String str2 = "Code point cp2 represents a letter is " + b2 // print b1, b2 values System.out.println( str1 ) System.out.println( str2 ) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Code point cp1 represents a letter is true Code point cp2 represents a letter is false