java.lang.Character.isHighSurrogate()是java中的内置方法,它确定给定的char值是否为Unicode high-surrogate代码单元(也称为leading-surrogate代码单元)。这样的值本身并不表示字符,而是用于UTF-16编码中的补充字符。
用法:
public static boolean isHighSurrogate(char ch)
参数:该函数接受单个强制参数ch,该参数指定要测试的值。
返回值:该函数返回一个布尔值。如果char值介于MIN_HIGH_SURROGATE和MAX_HIGH_SURROGATE(含)之间,则返回的值为True,否则为False。
以下示例程序旨在说明Character.isHighSurrogate()方法:
示例1:
// Java program to illustrate the
// Character.isHighSurrogate() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives c1, c2
char c1 = '\u0a4f', c2 = '\ud8b4';
// assign isHighSurrogate results of
// c1, c2 to boolean primitives bool1, bool2
boolean bool1 = Character.isHighSurrogate(c1);
System.out.println("c1 is a Unicode"+
"high-surrogate code unit ? " + bool1);
boolean bool2 = Character.isHighSurrogate(c2);
System.out.println("c2 is a Unicode"+
"high-surrogate code unit ? " + bool2);
}
}
输出:
c1 is a Unicodehigh-surrogate code unit ? false c2 is a Unicodehigh-surrogate code unit ? true
示例2:
// Java program to illustrate the
// Character.isHighSurrogate() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives c1, c2
char c1 = '\u0b9f', c2 = '\ud5d5';
// assign isHighSurrogate results of
// c1, c2 to boolean primitives bool1, bool2
boolean bool1 = Character.isHighSurrogate(c1);
System.out.println("c1 is a Unicode" +
"high-surrogate code unit ? " + bool1);
boolean bool2 = Character.isHighSurrogate(c2);
System.out.println("c2 is a Unicode" +
"high-surrogate code unit ? " + bool2);
}
}
输出:
c1 is a Unicodehigh-surrogate code unit ? false c2 is a Unicodehigh-surrogate code unit ? false
相关用法
- Java Java lang.Long.byteValue()用法及代码示例
- Java Java lang.Long.reverse()用法及代码示例
- Java Java lang.Long.builtcount()用法及代码示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代码示例
- Java Java.util.Collections.disjoint()用法及代码示例
- Java Java lang.Long.numberOfLeadingZeros()用法及代码示例
- Java Java lang.Long.highestOneBit()用法及代码示例
- Java Java.util.Collections.rotate()用法及代码示例
- Java Java lang.Long.lowestOneBit()用法及代码示例
- Java Clock withZone()用法及代码示例
- Java Clock tickMinutes()用法及代码示例
- Java Map get()用法及代码示例
- Java Set contains()用法及代码示例
注:本文由纯净天空筛选整理自Twinkl Bajaj大神的英文原创作品 Character.isHighSurrogate() method in Java with examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。