java.lang.Character.isLowSurrogate(char ch)是java中的一種內置方法,它確定給定的char值是否為Unicode low-surrogate代碼單元(也稱為trailing-surrogate代碼單元)。這樣的值本身並不表示字符,而是用於UTF-16編碼中的補充字符。
用法:
public static boolean isLowSurrogate(char ch)
參數:該函數接受一個強製性參數ch,該參數指定要測試的字符。
返回值:該函數返回一個布爾值。如果char值介於MIN_LOW_SURROGATE和MAX_LOW_SURROGATE(含)之間,則返回的值為True,否則為False。
以下示例程序旨在說明Character.isLowSurrogate()方法:
示例1:
// Java program to illustrate the
// Character.isLowSurrogate() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives c1, c2
char c1 = '\udc25', c2 = 'h';
// assign isLowSurrogate results of
// c1, c2 to boolean primitives bool1, bool2
boolean bool1 = Character.isLowSurrogate(c1);
System.out.println("c1 is a Unicode low-surrogate ? " + bool1);
boolean bool2 = Character.isLowSurrogate(c2);
System.out.println(c2 + " is a Unicode low-surrogate ? " + bool2);
}
}
輸出:
c1 is a Unicode low-surrogate ? true h is a Unicode low-surrogate ? false
示例2:
// Java program to illustrate the
// Character.isLowSurrogate() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives c1, c2
char c1 = '\udc29', c2 = 'x';
// assign isLowSurrogate results of
// c1, c2 to boolean primitives bool1, bool2
boolean bool1 = Character.isLowSurrogate(c1);
System.out.println("c1 is a Unicode low-surrogate ? " + bool1);
boolean bool2 = Character.isLowSurrogate(c2);
System.out.println(c2 + " is a Unicode low-surrogate ? " + bool2);
}
}
輸出:
c1 is a Unicode low-surrogate ? true x is a Unicode low-surrogate ? false
參考: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isLowSurrogate(char)
相關用法
- 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.isLowSurrogate() method in Java with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。