You can directly call the static function of Integer to determine whether str is an integer.
int str toint = integer . parse int(str);
If an exception is thrown, the string is not an integer.
You can use try{} catch{} to catch and analyze exceptions.
ParseInt API documentation
Public static int parseInt (string s)
Raise NumberFormatException
Parses a string parameter into a signed decimal integer. All characters in a string must be decimal numbers except that the first character can be the ASCII minus sign' -' ('\u002D') used to represent negative values. Returns the obtained Integer value, just like giving this parameter and radix 10 as parameters to the parseInt(java.lang.String, int) method.
Parameters:
S- a string containing the int representation to be parsed.
Return:
An integer value expressed as a decimal parameter.
Throwing:
If the string does not contain parseable integers.