@Test public void testIsNumber() { assertFalse(isNumber(null)); assertFalse(isNumber("")); assertFalse(isNumber("a")); assertFalse(isNumber("-a")); assertFalse(isNumber("23a")); assertTrue(isNumber("-1")); assertTrue(isNumber("0")); assertTrue(isNumber("12345")); }
public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }
WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; } }
WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }  }
WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }  static String getLastWord(final String sentence); static String capitalize(final String str); static boolean isNumber(String word); }
WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigit(c)) { return false; } } return true; }  static String getLastWord(final String sentence); static String capitalize(final String str); static boolean isNumber(String word);  }