Exception in thread main java.util.InputMismatchException error

前端 未结 5 2093
孤街浪徒
孤街浪徒 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:03

    Issues

     int name; //Name should be of type String
     ...
     System.out.println("Enter in your name");
     name = in.nextInt(); //It doesn't handle the string since your using `nextInt`
    

    Solution

     String name;
     ...
     System.out.println("Enter in your name");
     name = in.nextLine();
    

提交回复
热议问题