全屏
java.lang.Character.isUpperCase(int codePoint)确定指定字符(Unicode代码点)是否为一个大写字母。
字符是大写,如果它的一般类别类型,通过getType(codePoint)所提供的UPPERCASE_LETTER,或属性为Other_Uppercase Unicode标准的定义。
声明
以下是java.lang.Character.isUpperCase()方法的声明public static boolean isUpperCase(int codePoint)
参数codePoint - 要进行测试的字符(Unicode代码点)
返回值
如果字符是大写此方法返回true,否则为false。
异常NA
例子
下面的例子显示lang.Character.isUpperCase()方法的使用。package cn.sxt;
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 = 0x004a; // represents J
cp2 = 0x0071; // represents x
// create 2 boolean primitives b1, b2
boolean b1, b2;
// check if cp1, cp2 are uppercase and assign results to b1, b2
b1 = Character.isUpperCase(cp1);
b2 = Character.isUpperCase(cp2);
String str1 = "cp1 is uppercase character is " + b1;
String str2 = "cp2 is uppercase character is " + b2;
// print b1, b2 values
System.out.println( str1 );
System.out.println( str2 );
}
}
让我们来编译和运行上面的程序,这将产生以下结果:
cp1 is uppercase character is true
cp2 is uppercase character is false
分享到:
0评论