Character 类的 isHighSurrogate(char ch) 方法判断给定值是否为高代理代码单元,也称为前导代理代码单元。
这些值本身不能用于表示字符,但可以用于表示 UTF-16 编码中的增补字符。
用法
public static boolean isHighSurrogate(char ch)
参数
上述方法只需要一个参数:
a.)需要测试的字符值。
返回值
isHighSurrogate(char ch) 方法返回一个布尔值,即如果字符的值位于 MIN_HIGH_SURROGATE 和 MAX_HIGH_SURROGATE 之间,则返回 true。否则,此方法返回 false。
例子1
public class JavaCharacterisHighSurrogateExample1 {
public static void main(String[] args) {
// Initialize the characters that need to be tested.
char c1 = '\ud800';
char c2 = '\uc71f';
char c3 = '\u1016';
// Check the individual character whether it is
boolean result1 = Character.isHighSurrogate(c1);
boolean result2 = Character.isHighSurrogate(c2);
boolean result3 = Character.isHighSurrogate(c3);
// print the result
System.out.println("The first character is a Unicode high-surrogate code unit:"+ result1);
System.out.println("The second character is a Unicode high-surrogate code unit:"+ result2);
System.out.println("The third character is a Unicode high-surrogate code unit:"+ result3);
}
}
输出:
The first character is a Unicode high-surrogate code unit:true The second character is a Unicode high-surrogate code unit:false The third character is a Unicode high-surrogate code unit:false
例子2
public class JavaCharacterisHighSurrogateExample2 {
public static void main(String args[])
{
//Initialize two char value
char a1 ='Z';
char a2 ='z';
//Create two object obj1 and obj2.
Character obj1 =new Character(a1);
Character obj2 =new Character(a2);
//Check whether the given charactesr 'obj' and 'obj2' are isHighSurrogate or not.
boolean b1 = obj1.isHighSurrogate(a1);
boolean b2 = obj2.isHighSurrogate(a2);
//Print the values.
System.err.println("The character 'Z' is a Unicode high-surrogate code unit:"+b1);
System.err.println("The character 'z' is a Unicode high-surrogate code unit:"+b2);
}
}
输出:
The character 'Z' is a Unicode high-surrogate code unit:false The character 'z' is a Unicode high-surrogate code unit:false
相关用法
- Java Character isLetter()用法及代码示例
- Java Character isAlphabetic()用法及代码示例
- Java Character isValidCodePoint()用法及代码示例
- Java Character isISOControl()用法及代码示例
- Java Character isSpace()用法及代码示例
- Java Character isMirrored()用法及代码示例
- Java Character isBmpCodePoint()用法及代码示例
- Java Character isIdentifierIgnorable()用法及代码示例
- Java Character isDigit()用法及代码示例
- Java Character isLowerCase()用法及代码示例
- Java Character isJavaIdentifierPart()用法及代码示例
- Java Character isUpperCase()用法及代码示例
- Java Character isLowSurrogate()用法及代码示例
- Java Character isJavaLetterOrDigit()用法及代码示例
- Java Character isWhitespace()用法及代码示例
- Java Character isDefined()用法及代码示例
- Java Character isJavaIdentifierstart()用法及代码示例
- Java Character isLetterOrDigit()用法及代码示例
- Java Character isSpaceChar()用法及代码示例
- Java Character codePointCount()用法及代码示例
注:本文由纯净天空筛选整理自 Java Character isHighSurrogate() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。