![]() |
细心的针织衫 · 深受各国大使喜爱的日光国立公园 2天1夜 ...· 6 月前 · |
![]() |
热心的黄花菜 · EveryDay/Linux/curl命令. ...· 6 月前 · |
![]() |
无邪的灯泡 · 用fastgit加速github· 8 月前 · |
![]() |
打篮球的自行车 · 首頁 - 臺北市立大安高工· 9 月前 · |
![]() |
聪明伶俐的柠檬 · 人力资源数据分析_考勤报表_薪酬分析_招聘分 ...· 11 月前 · |
Apart from the above mentioned ranges, many other character ranges contain digits as well.
Syntax:
Parameter: This method accepts character parameter ch as an argument, which is to be tested.
Return value: This method returns a boolean value. It returns True if ch is digit, else False.
Note: This method cannot handle supplementary characters . To support all Unicode characters, including supplementary characters, use the isDigit(int) method.
Below programs illustrate the above method:
Program 1:
// Function to check if is digit
// is found or not
for
(
int
i =
0
; i < s.length(); i++) {
if
(Character.isDigit(
s.charAt(i))
==
true
) {
// return position of digit
return
i +
1
;
// return 0 if digit not present
return
0
;
public
static
void
main(String[] args)
// Array of strings
String[] arr = {
"ABC4DEF"
,
"QWERTY"
};
// To store the position of digit
int
index =
0
;
// Traverse the array arr[] to find digit
// within it's elements
for
(String x : arr) {
index = search_digit(x);
if
(index !=
0
) {
System.out.println(
"Digit found at : "
+ (index)
+
"th position."
);
else
{
System.out.println(
"Digit not present."
);
Apart from the above mentioned ranges, many other character ranges contain digits as well.
Syntax:
Parameter: This method accepts unicode character parameter codePoint of integer type as an argument, which is to be tested.
Return value: This method returns a boolean value. It returns True if the specified character is digit, else it returns False.
Below programs illustrate the above method:
Program 1:
// This program demonstrates the use of
// isDigit(int codePoint) method of Character class.
import
java.util.*;
public
class
GFG {
public
static
void
main(String[] args)
// create codePoints
int
cp1 =
57
;
int
cp2 =
84
;
// Check whether the codePoints
// are digit or not.
System.out.println(
"The codePoint cp1 is a digit -> "
+ Character.isDigit(cp1));
System.out.println(
"The codePoint cp2 is a digit -> "
+ Character.isDigit(cp2));
// This program demonstrates the use of
// isDigit(int codePoint) method of
// Character class.
import
java.util.*;
public
class
Main {
public
static
void
main(String[] args)
// create codePoints
int
cp1 =
0x50
;
int
cp2 =
0x06f8
;
// Check whether the codePoints
// are digit or not.
System.out.println(
"The codePoint cp1 is a digit -> "
+ Character.isDigit(cp1));
System.out.println(
"The codePoint cp2 is a digit -> "
+ Character.isDigit(cp2));
![]() |
无邪的灯泡 · 用fastgit加速github 8 月前 |
![]() |
打篮球的自行车 · 首頁 - 臺北市立大安高工 9 月前 |
![]() |
聪明伶俐的柠檬 · 人力资源数据分析_考勤报表_薪酬分析_招聘分析-九数云 11 月前 |