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?

3
  • 2
    What kind of input isn't a string? Commented Dec 14, 2014 at 13:42
  • sorry what i meant was if input contains numeric data, i know numeric data is also consider as String, So any solution? Commented Dec 14, 2014 at 13:52
  • @user3666220 Check this out Commented Dec 14, 2014 at 13:55

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.