Use static method Integer.parseInt() and catch the exception that is thrown when the number cannot be parsed.
String s = "123";
boolean isValidInteger = false;
try
{
int i = Integer.parseInt(s);
// s is a valid integer
isValidInteger = true;
}
catch (NumberFormatException ex)
{
// s is not an integer
}
Subscribe to:
Post Comments (Atom)
1 comment:
Test Comment
Post a Comment