Java Character isSupplementaryCodePoint()方法

Java Character isSupplementaryCodePoint()方法

java.lang.Character.isSupplementaryCodePoint(int codePoint) 是java中的一个内置方法,用于确定指定的字符(Unicode码位)是否在补充字符范围内。

语法

public static boolean isSupplementaryCodePoint(int codePoint)

参数: 整数类型的codePoint指的是要测试的字符(Unicode码位)。

返回值: 如果指定的码位在MIN_SUPPLEMENTARY_CODE_POINT和MAX_CODE_POINT之间,该方法返回真,否则返回假。

下面的程序说明了Character.isSupplementaryCodePoint()方法。

程序1 :

// Code to illustrate the isSupplementaryCodePoint() method
import java.lang.*;
  
public class gfg {
  
    public static void main(String[] args)
    {
  
        // Create 2 int primitives c1, c2 and assign values
        int c1 = 0x10ffd, c2 = 0x154ca;
  
        boolean bool1 = Character.isSupplementaryCodePoint(c1);
        boolean bool2 = Character.isSupplementaryCodePoint(c2);
  
        String str1 = "c1 represents a supplementary code point is " + bool1;
        String str2 = "c2 represents a supplementary code point is " + bool2;
  
        // Displaying the result
        System.out.println(str1);
        System.out.println(str2);
    }
}

输出:

c1 represents a supplementary code point is true
c2 represents a supplementary code point is true

程序2

// Code to illustrate the isSupplementaryCodePoint() method
import java.lang.*;
  
public class gfg {
  
    public static void main(String[] args)
    {
  
        // Creates 2 int primitives c1, c2 and assign values
        int c1 = 0x45ffd, c2 = 0x004ca;
  
        boolean bool1 = Character.isSupplementaryCodePoint(c1);
        boolean bool2 = Character.isSupplementaryCodePoint(c2);
  
        String str1 = "c1 represents a supplementary code point is " + bool1;
        String str2 = "c2 represents a supplementary code point is " + bool2;
         
        // Displaying the result
        System.out.println(str1);
        System.out.println(str2);
    }
}

输出:

c1 represents a supplementary code point is true
c2 represents a supplementary code point is false

参考资料 : https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isSupplementaryCodePoint(int)

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Java 参考指南