java.lang.Character.isSpaceChar(char ch)是java中的一個內置方法,該方法確定指定字符是否為Unicode空格字符。當且僅當Unicode標準將其指定為空格字符時,才將其視為空格字符。
如果角色的常規類別類型是以下任意一種,則此方法返回true?
- SPACE_SEPARATOR
- LINE_SEPARATOR
- PARAGRAPH_SEPARATOR
用法:
public static boolean isSpaceChar(char ch)
參數:該函數接受一個強製性參數ch,該參數指定要測試的字符。
返回值:此方法返回一個布爾值。如果字符是空格字符,則值為True;否則為False。
以下示例程序旨在說明Character.isSpaceChar()方法:
示例1:
// Java program to illustrate the
// Character.isSpaceChar() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives c1, c2 and assign values
char c1 = '$', c2 = '\u2025';
// Function to check if the character is a unicode space or not
boolean bool1 = Character.isSpaceChar(c1);
System.out.println("c1 is a space character? " + bool1);
// Function to check if the character is a unicode space or not
boolean bool2 = Character.isSpaceChar(c2);
System.out.println("c2 is a space character? " + bool2);
}
}
輸出:
c1 is a space character? false c2 is a space character? false
示例2:
// Java program to illustrate the
// Character.isSpaceChar() method
import java.lang.*;
public class gfg {
public static void main(String[] args)
{
// create 2 char primitives
// c1, c2 and assign values
char c1 = '*', c2 = '\u2028';
// Function to check if the character is a unicode space or not
boolean bool1 = Character.isSpaceChar(c1);
System.out.println("c1 is a space character? " + bool1);
// Function to check if the character is a unicode space or not
boolean bool2 = Character.isSpaceChar(c2);
System.out.println("c2 is a space character? " + bool2);
}
}
輸出:
c1 is a space character? false c2 is a space character? true
參考: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isSpaceChar(char)
相關用法
- Java Java lang.Long.numberOfLeadingZeros()用法及代碼示例
- Java Java.util.Collections.rotate()用法及代碼示例
- Java Java lang.Long.highestOneBit()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代碼示例
- Java Java lang.Long.lowestOneBit()用法及代碼示例
- Java Java lang.Long.reverse()用法及代碼示例
- Java Java lang.Long.builtcount()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
- Java Java.math.BigInteger.modInverse()用法及代碼示例
- Java Clock tickMinutes()用法及代碼示例
- Java Java.math.BigInteger.probablePrime()用法及代碼示例
- Java Java.util.ArrayList.addall()用法及代碼示例
注:本文由純淨天空篩選整理自Twinkl Bajaj大神的英文原創作品 Character.isSpaceChar() method in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。