0

I want to know if a particular exception is available for catching non-String input in java.

My purpose is that if a user enters other than String input, it goes to a catch block and displays "Enter String input".

I know that for numeric input there is NumberFormatException, so is there any Exception like this?

Eran
  • 387,369
  • 54
  • 702
  • 768
MateenSheikh
  • 152
  • 1
  • 10

1 Answers1

4

A numeric input can always be interpreted as a String, so there is no such exception.

You'll have to check the characters of the String to find out if it contains digits.

Eran
  • 387,369
  • 54
  • 702
  • 768