check if input is integer or string java code example
Example 1: java check if string is number
try {
int n = Integer.parseInt(str);
} catch (NumberFormatException e) {
// str is not a number
}
Example 2: how to check whether input is string or not
num = input("Enter your number ")
print("\n")
if num.isdigit():
print("User input is Number ")
else:
print("User input is string ")