Home java error in next.int ()

error in next.int ()

Author

Date

Category

When performing the next code (I will give only a piece with a problem)


Public Class Main {
  Public Static Void Main (String [] Args) {
    Scanner Scan = New Scanner (System.in);
    System.Out.printLN ("How Many Account You Want To Verify");
    INT COUNTACCOUNT = scan.nextint ();
    For (int i = 0; I & lt; CountAccount; I ++) {
      System.out.printLN ("ENTER YOUR LOGIN PLEASE");
      String Loginperson = scan.nextline ();
      System.Out.printLN ("ENTER YOUR ID PLEASE");
      int idperson = scan.nextint ();
      System.out.PrintLN (Loginperson + IDPerson);
    }
  }
}

Next error occurs

at java.base / java.util.scanner.throwfor (scanner.java:939)
  at java.base / java.util.scanner.next (scanner.java:1594)
  at java.base / java.util.scanner.nextint (scanner.java:2258)
  at java.base / java.util.scanner.nextint (scanner.java:22)
  at main.main (main.java:19)

please tell me what is the mistake? I see the first time this


Answer 1

Found this answer

system.out.println ("How Many Account You Want To Verify");
  int CountAccount = integer.parseint (scan.nextline ());
  For (int i = 0; I & lt; CountAccount; I ++) {
    System.out.printLN ("ENTER YOUR LOGIN PLEASE");
     loginperson = scan.nextline ();
    System.Out.printLN ("ENTER YOUR ID PLEASE");
    idperson = integer.paraseint (scan.nextline ());
    System.out.PrintLN (Loginperson + IDPerson);
  }

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions