Java InputMismatchException

后端 未结 3 1864
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 03:01

I have this code and I want to catch the letter exception but it keeps having these errors:

Exception in thread \"main\" java.util.InputMismatchException
            


        
3条回答
  •  悲哀的现实
    2020-12-06 03:57

    Reading data from Scanner and assigning it to Int type. Since you are supplying String this will throw exception. To handle this situation you must write your snippet inside Try- Catch block only.

提交回复
热议问题