Friday, 14 August 2015

Character: isDigit: Is character is a digit

java.lang.Character class provides isDigit method, to check whether given character is a digit or not. ‘isDigit’ method identifies
a.   ISO latin digits (0-9)
b.    Arabic-Indic digits ('\u0660' through '\u0669')
c.    Extended Arabic digits ('\u06F0' through '\u06F9')
d.   Devanagari digits ('\u0966' through '\u096F')
e.   Fullwidth digits ('\uFF10' through '\uFF19',)


There are two variant of isDigit method.
public class CharacterTest {
 public static void main(String args[]) {
  System.out.println(Character.isDigit('1'));
  System.out.println(Character.isDigit('a'));
  System.out.println(Character.isDigit('٢'));
  System.out.println(Character.isDigit('۷'));
 }
}


Output
true
false
true
true


No comments:

Post a Comment