Exception in thread main java.util.InputMismatchException error

前端 未结 5 2094
孤街浪徒
孤街浪徒 2020-12-22 10:39

I have a question on what\'s going on, whenever I try to compile it it keeps giving me an error like this:

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


        
5条回答
  •  孤城傲影
    2020-12-22 11:04

    Why is name an integer? int name;

    I suspect you are using alpha characters to input your name...and are getting the exception at this line: name = in.nextInt();

    name should not be an integer. It should be a string.

    Therefore, string name; and name = in.nextLine();

提交回复
热议问题