๐์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ๋ฅผ ํ๋ค๊ฐ, ์ ์ฉํ๊ฒ ์ด ๋ฉ์๋๋ฅผ ์์ง ์์ผ๋ ค๊ณ ํฌ์คํ ํด๋ณธ๋ค.
๐ ๋ฌธ์๊ฐ ์ซ์์ธ์ง ํ๋จ
- ์๋์ ์ค๋ช ์ ์ฐธ์กฐํ๋ฉด '1' ~ '9' ๊น์ง์ ์ซ์๊ฐ ๋ค์ด์ค๋ฉด true๊ฐ ๋ฐํ๋๋ค๋ ๊ฒ์ ์ ์ ์๋ค.
/*
Determines if the specified character is a digit.
A character is a digit if its general category type, provided by Character.getType(ch), is DECIMAL_DIGIT_NUMBER.
Some Unicode character ranges that contain digits:
'\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9')
'\u0660' through '\u0669', Arabic-Indic digits
'\u06F0' through '\u06F9', Extended Arabic-Indic digits
'\u0966' through '\u096F', Devanagari digits
'\uFF10' through '\uFF19', Fullwidth digits
Many other character ranges contain digits as well.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isDigit(int) method.
๋งค๊ฐ๋ณ์:
ch – the character to be tested.
๋ฐํ:
true if the character is a digit; false otherwise.
*/
public static boolean isDigit(char ch) {
return isDigit((int)ch);
}
๐ ๋ฌธ์๊ฐ ๋ฌธ์์ธ์ง ํ๋จ
- ์๋์ ์ค๋ช ์ ์ฐธ์กฐํ๋ฉด ๋๋ฌธ์, ์๋ฌธ์ ๋ฑ์ ๋ฌธ์๊ฐ ๋ค์ด์ค๋ฉด true๊ฐ ๋ฐํ๋จ์ ์ ์ ์๋ค.
/*
Determines if the specified character is a letter.
A character is considered to be a letter if its general category type, provided by Character.getType(ch), is any of the following:
• UPPERCASE_LETTER
• LOWERCASE_LETTER
• TITLECASE_LETTER
• MODIFIER_LETTER
• OTHER_LETTER
Not all letters have case. Many characters are letters but are neither uppercase nor lowercase nor titlecase.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the isLetter(int) method.
๋งค๊ฐ๋ณ์:
ch – the character to be tested.
๋ฐํ:
true if the character is a letter; false otherwise.
*/
public static boolean isLetter(char ch) {
return isLetter((int)ch);
}
โ๏ธ ์ถ๋ ฅ ์์
public class CheckCharacter {
public static void main(String[] args) {
System.out.println(Character.isDigit('7'));
System.out.println(Character.isLetter('๊ฐ'));
}
}
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] ํ๋์ ๋ฉ์๋ (0) | 2022.12.26 |
---|---|
[JAVA] ํด๋์ค์ ๊ฐ์ฒด (0) | 2022.12.22 |
[Java] ๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ (OOP) (0) | 2022.12.20 |
[Java] ๋ฐฐ์ด(Array) (0) | 2022.12.19 |
[Java] ์ ์ด๋ฌธ - ๋ฐ๋ณต๋ฌธ (for, ํฅ์๋ for, while, do-while, break, continue) (0) | 2022.12.16 |
๋๊ธ