Character 類的 isAlphabetic(intcodePoint) 方法確定指定字符是否為字母表。
如果字符具有以下特征,則將其視為字母表:
- 大寫_字母
- LOWERCASE_LETTER
- TITLECASE_LETTER
- MODIFIER_LETTER
- OTHER_LETTER
- LETTER_NUMBER 或
- Unicode 標準定義的其他字母表。
用法
public static Boolean isAlphabetic(int codePoint)
參數
codePoint: 這是要測試的字符。
返回值
如果字符是 Unicode 字母字符,則 isAlphabetic(intcodePoint) 方法返回 true。否則,此方法返回 false。
例子1
public class JavaCharacterisAlphabeticExample1 {
public static void main(String[] args) {
char codepoint1 = '0';
char codepoint2 = '1';
boolean b1 = Character.isAlphabetic(codepoint1);
boolean b2 = Character.isAlphabetic(codepoint2);
System.out.println("The returned value for the first character is given as:"+" "+b1);
System.out.println("The returned value for the first character is given as:"+" "+b2);
}
}
輸出:
The returned value for the first character is given as: false The returned value for the first character is given as: false
例子2
public class JavaCharacterisAlphabeticExample2 {
public static void main(String[] args) {
// Initialize the codepoints
int codepoint1 = 87;
int codepoint2 = 49;
int codepoint3 = 63;
// Check if the first codepoint is alphabet or not.
boolean checkAlp1 = Character.isAlphabetic(codepoint1);
if(checkAlp1){
System.err.print("Codepoint \'"+codepoint1+"\' is an alphabet.\n");
}
else{
System.out.print("Codepoint \'"+codepoint1+"\' is not an alphabet.\n");
}
// Check if the second codepoint is alphabet or not.
boolean checkAlp2 = Character.isAlphabetic(codepoint2);
if(checkAlp2){
System.err.print("Codepoint \'"+codepoint2+"\' is an alphabet.\n");
}
else{
System.out.print("Codepoint \'"+codepoint2+"\' is not an alphabet.\n");
}
// Check if the third codepoint is alphabet or not.
boolean checkAlp3 = Character.isAlphabetic(codepoint3);
if(checkAlp3){
System.err.print("Codepoint \'"+codepoint3+"\' is an alphabet.\n");
}
else{
System.out.print("Codepoint \'"+codepoint3+"\' is not an alphabet.\n");
}
}
}
輸出:
Codepoint '87' is an alphabet. Codepoint '49' is not an alphabet. Codepoint '63' is not an alphabet.
例子3
public class JavaCharacterisAlphabeticExample3 {
public static void main(String[] args) {
char codepoint1 = '1';
char codepoint2 = 'A';
char codepoint3 ='B';
boolean b1 = Character.isAlphabetic(codepoint1);
boolean b2 = Character.isAlphabetic(codepoint2);
boolean b3 = Character.isAlphabetic(codepoint3);
System.out.println("The returned value for the first character is given as:"+" "+b1);
System.out.println("The returned value for the second character is given as:"+" "+b2);
System.out.println("The returned value for the third character is given as:"+" "+b3);
}
}
輸出:
The returned value for the first character is given as: false The returned value for the second character is given as: true The returned value for the third character is given as: true
相關用法
- Java Character isLetter()用法及代碼示例
- Java Character isValidCodePoint()用法及代碼示例
- Java Character isISOControl()用法及代碼示例
- Java Character isSpace()用法及代碼示例
- Java Character isMirrored()用法及代碼示例
- Java Character isBmpCodePoint()用法及代碼示例
- Java Character isIdentifierIgnorable()用法及代碼示例
- Java Character isDigit()用法及代碼示例
- Java Character isLowerCase()用法及代碼示例
- Java Character isJavaIdentifierPart()用法及代碼示例
- Java Character isUpperCase()用法及代碼示例
- Java Character isLowSurrogate()用法及代碼示例
- Java Character isJavaLetterOrDigit()用法及代碼示例
- Java Character isWhitespace()用法及代碼示例
- Java Character isDefined()用法及代碼示例
- Java Character isJavaIdentifierstart()用法及代碼示例
- Java Character isHighSurrogate()用法及代碼示例
- Java Character isLetterOrDigit()用法及代碼示例
- Java Character isSpaceChar()用法及代碼示例
- Java Character codePointCount()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Character isAlphabetic() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。