@Test public void isNumber_true() { Assert.assertTrue(Util.isNumber("0")); Assert.assertTrue(Util.isNumber("1")); Assert.assertTrue(Util.isNumber("+1")); Assert.assertTrue(Util.isNumber("-1")); Assert.assertTrue(Util.isNumber("100")); Assert.assertTrue(Util.isNumber("+100")); Assert.assertTrue(Util.isNumber("-100")); }
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);  }