@Test public void isNumber_false() { Assert.assertFalse(Util.isNumber(null)); Assert.assertFalse(Util.isNumber("")); Assert.assertFalse(Util.isNumber("a")); Assert.assertFalse(Util.isNumber("1-")); }
public static boolean isNumber(String value) { if (value != null) { int n = value.length(); for (int i = 0; i < n; i++) { char x = value.charAt(i); if (!Character.isDigit(x) && !(i == 0 && (x == '-' || x == '+'))) { return false; } } return n > 0; } return false; }
Util { public static boolean isNumber(String value) { if (value != null) { int n = value.length(); for (int i = 0; i < n; i++) { char x = value.charAt(i); if (!Character.isDigit(x) && !(i == 0 && (x == '-' || x == '+'))) { return false; } } return n > 0; } return false; } }
Util { public static boolean isNumber(String value) { if (value != null) { int n = value.length(); for (int i = 0; i < n; i++) { char x = value.charAt(i); if (!Character.isDigit(x) && !(i == 0 && (x == '-' || x == '+'))) { return false; } } return n > 0; } return false; } private  Util(); }
Util { public static boolean isNumber(String value) { if (value != null) { int n = value.length(); for (int i = 0; i < n; i++) { char x = value.charAt(i); if (!Character.isDigit(x) && !(i == 0 && (x == '-' || x == '+'))) { return false; } } return n > 0; } return false; } private  Util(); static boolean isNumber(String value); }
Util { public static boolean isNumber(String value) { if (value != null) { int n = value.length(); for (int i = 0; i < n; i++) { char x = value.charAt(i); if (!Character.isDigit(x) && !(i == 0 && (x == '-' || x == '+'))) { return false; } } return n > 0; } return false; } private  Util(); static boolean isNumber(String value);  }