性格Java中的isHighSurrogate()方法及其示例

这个 JAVA朗,性格。Ishighrogate() 是java中的一种内置方法,用于确定给定的字符值是否为Unicode高级代理代码单元(也称为前导代理代码单元)。这些值本身并不表示字符,而是用于表示UTF-16编码中的补充字符。

语法:

public static boolean isHighSurrogate(char ch)

参数: 该函数只接受一个强制参数 中国 它指定了要测试的值。

返回值: 该函数返回一个布尔值。返回的值为 符合事实的 如果char值介于MIN_HIGH_subrogate和MAX_HIGH_subrogate(含)之间, 错误的 否则

下面的程序说明了这个角色。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

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞13 分享