![]() |
爽快的石榴 · iOS 11全版本越狱发布,支持所有64位设备· 3 月前 · |
![]() |
无邪的灌汤包 · 3dmax2018注册机下载和64位激活教程 ...· 5 月前 · |
![]() |
风流的匕首 · 社区治理要面向人民群众对高品质生活的追求-光 ...· 1 年前 · |
![]() |
痴情的毛衣 · 使用FFmpeg对多路摄像头进行解码 ...· 1 年前 · |
![]() |
谈吐大方的烤土司 · python3最全知识点,从入门到开车就是这 ...· 1 年前 · |
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));
![]() |
爽快的石榴 · iOS 11全版本越狱发布,支持所有64位设备 3 月前 |