publicbooleanisNumeric(char[] str){ String s = new String(str); if (s.startsWith("+") || s.startsWith("-")) { s = s.substring(1); } if (s.matches("[0-9]+.*")) { s = s.replaceFirst("[0-9]+", ""); if ("".equals(s)) { returntrue; } }
if (s.startsWith(".")) { s = s.substring(1); if (!s.matches("[0-9]+.*")) { returnfalse; } s = s.replaceFirst("[0-9]+", ""); } if ("".equals(s)) { returntrue; }
if (s.startsWith("e") || s.startsWith("E")) { s = s.substring(1); if (s.startsWith("+") || s.startsWith("-")) { s = s.substring(1); } if (!s.matches("[0-9]+")) { returnfalse; } else { returntrue; } } else { returnfalse; } }