List of usage examples for java.lang Character isDigit
public static boolean isDigit(int codePoint)
From source file:Main.java
public static void main(String[] args) throws java.io.IOException { char c = 'a'; System.out.println("Character = " + (int) c); System.out.println("Defined = " + Character.isDefined(c)); System.out.println("Digit = " + Character.isDigit(c)); System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c)); System.out.println("ISO control = " + Character.isISOControl(c)); System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c)); System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c)); System.out.println("Letter = " + Character.isLetter(c)); System.out.println("Letter or digit = " + Character.isLetterOrDigit(c)); System.out.println("Lowercase = " + Character.isLowerCase(c)); System.out.println("Space = " + Character.isSpaceChar(c)); System.out.println("Titlecase = " + Character.isTitleCase(c)); System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c)); System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c)); System.out.println("Uppercase = " + Character.isUpperCase(c)); System.out.println("White space = " + Character.isWhitespace(c)); byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL, Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER, Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER, Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL, Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER, Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL, Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR, Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED, Character.UPPERCASE_LETTER }; String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol", "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format", "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol", "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol", "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate", "Titlecase letter", "Unassigned", "Uppercase letter" }; int type = Character.getType(c); for (int i = 0; i < types.length; i++) if (type == types[i]) { System.out.println("Type name = " + typeNames[i]); break; }// w ww. j a va2 s. c o m System.out.println("Unicode block = " + Character.UnicodeBlock.of(c)); }
From source file:Classify.java
public static void main(String[] args) throws java.io.IOException { char c = '\u0beb'; // Tamil digit. System.out.println("Character = " + (int) c); System.out.println("Defined = " + Character.isDefined(c)); System.out.println("Digit = " + Character.isDigit(c)); System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c)); System.out.println("ISO control = " + Character.isISOControl(c)); System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c)); System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c)); System.out.println("Letter = " + Character.isLetter(c)); System.out.println("Letter or digit = " + Character.isLetterOrDigit(c)); System.out.println("Lowercase = " + Character.isLowerCase(c)); System.out.println("Space = " + Character.isSpaceChar(c)); System.out.println("Titlecase = " + Character.isTitleCase(c)); System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c)); System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c)); System.out.println("Uppercase = " + Character.isUpperCase(c)); System.out.println("White space = " + Character.isWhitespace(c)); byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL, Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER, Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER, Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL, Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER, Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL, Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR, Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED, Character.UPPERCASE_LETTER }; String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol", "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format", "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol", "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol", "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate", "Titlecase letter", "Unassigned", "Uppercase letter" }; int type = Character.getType(c); for (int i = 0; i < types.length; i++) if (type == types[i]) { System.out.println("Type name = " + typeNames[i]); break; }//from w ww.j a va 2 s .c om System.out.println("Unicode block = " + Character.UnicodeBlock.of(c)); }
From source file:Main.java
public static void main(String[] args) { // Using the constructor Character c1 = new Character('A'); // Using the factory method - preferred Character c2 = Character.valueOf('2'); Character c3 = Character.valueOf('-'); // Getting the wrapped char values char cc1 = c1.charValue(); char cc2 = c2.charValue(); char cc3 = c3.charValue(); System.out.println("c1 = " + c1); System.out.println("c2 = " + c2); System.out.println("c3 = " + c3); // Using some Character class methods on c1 System.out.println("isLowerCase c1 = " + Character.isLowerCase(cc1)); System.out.println("isDigit c1 = " + Character.isDigit(cc1)); System.out.println("isLetter c1 = " + Character.isLetter(cc1)); System.out.println("Lowercase of c1 = " + Character.toLowerCase(cc1)); // Using some Character class methods on c2 System.out.println("isLowerCase c2 = " + Character.isLowerCase(cc2)); System.out.println("isDigit c2 = " + Character.isDigit(cc2)); System.out.println("isLetter c2 = " + Character.isLetter(cc2)); System.out.println("Lowercase of c2 = " + Character.toLowerCase(cc2)); System.out.println("Uppercase of c3 = " + Character.toUpperCase(cc3)); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); // Create the main window Shell shell = new Shell(display); Text fahrenheit = new Text(shell, SWT.BORDER); fahrenheit.setData("Type a temperature in Fahrenheit"); fahrenheit.setBounds(20, 20, 100, 20); fahrenheit.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent event) { // Assume we don't allow it event.doit = false;//from ww w .j a v a2s . co m // Get the character typed char myChar = event.character; String text = ((Text) event.widget).getText(); // Allow '-' if first character if (myChar == '-' && text.length() == 0) event.doit = true; // Allow 0-9 if (Character.isDigit(myChar)) event.doit = true; // Allow backspace if (myChar == '\b') event.doit = true; } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Main.java
public static boolean containsOnlyNumbers(String str) { for (int i = 0; i < str.length(); i++) { if (!Character.isDigit(str.charAt(i))) return false; }/*from w ww . jav a2 s . co m*/ return true; }
From source file:Main.java
public static final boolean isXMLNameChar(char c) { return Character.isLetter(c) || Character.isDigit(c) || c == '.' || c == '-' || c == '_' || c == ':'; }
From source file:Main.java
public static boolean isNumeric(String str) { for (int i = str.length(); --i >= 0;) { if (!Character.isDigit(str.charAt(i))) { return false; }//w w w .ja v a2 s. c o m } return true; }
From source file:Main.java
public static boolean IsYearCorrect(String sRhs) { for (int i = 0; i < sRhs.length(); ++i) if (!Character.isDigit(sRhs.charAt(i))) return false; return true;//from w ww .jav a 2s . com }
From source file:Main.java
public static boolean isExistNumber(String str) { for (Character c : str.toCharArray()) { if (Character.isDigit(c)) { return true; }// ww w .j a va 2 s .c o m } return false; }
From source file:Main.java
public static boolean isExistSpecialSymbols(String str) { for (Character c : str.toCharArray()) { if (!Character.isDigit(c)) { if (!Character.isLetter(c)) { return true; }//from w ww . j av a2s . co m } } return false; }