Home java Twice triggers the output to the console in the cycle (Java)

Twice triggers the output to the console in the cycle (Java)

Author

Date

Category

When starting the loop, it displays twice the string at once. “Enter the surname and name, and press ENTER:”. Where did you miss?

int weight = 0;
  INT COUNT = 0;
System.out.PrintLN ("Enter blah blah blah and press ENTER:");
    Scanner Scan = New Scanner (System.in);
    Weight = scan.nextint ();
    System.out.PrintLN ("Enter blah blah blah enter:");
    Count = scan.nextint ();
    ArrayList & LT; String & GT; ArrayList = New ArrayList & lt; & gt; ();
    System.Out.printLN ("Enter Parameters");
    For (int i = 1; i & lt; = count; i ++) {
      System.Out.printLN ("Enter the name and name and press ENTER through the comma);
      arraylist.add (scan.nextline ());
      }

Answer 1

changed the penultimate line. Everything has earned. Thanks for the prompts.

int weight = 0;
  INT COUNT = 0;
System.out.PrintLN ("Enter blah blah blah and press ENTER:");
    Scanner Scan = New Scanner (System.in);
    Weight = scan.nextint ();
    System.out.PrintLN ("Enter blah blah blah enter:");
    Count = scan.nextint ();
    ArrayList & LT; String & GT; ArrayList = New ArrayList & lt; & gt; ();
    System.Out.printLN ("Enter Parameters");
    For (int i = 1; i & lt; = count; i ++) {
      System.Out.printLN ("Enter the name and name and press ENTER through the comma);
      arraylist.add (scan.next ());
      }

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