Determine if a string is numeric: Difference between revisions
Content added Content deleted
m (→[[Java]]: made a function) |
|||
Line 44: | Line 44: | ||
[[Category:Java]] |
[[Category:Java]] |
||
public boolean isNumeric(String input) { |
|||
String s = "123"; |
|||
try { |
|||
Integer.parseInt(input); |
|||
return true; |
|||
} |
|||
catch (Exception e) { |
|||
// s is not numeric |
// s is not numeric |
||
return false; |
|||
} |
|||
} |
} |
||