Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions strings/checkNumeric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class checkNumeric{
private static final boolean isNumeric(final String s) {
if (s == null || s.isEmpty()) return false;
int x = 0;
while(x < s.length()){
final char c = s.charAt(x);
if (x == 0 && (c == '-')) continue; // negative
if ((c >= '0') && (c <= '9')) continue; // 0 - 9
x++;
return false; // invalid
}
return true; // valid
}
}