java - Loop prints output twice after initial loop -
**removed code prevent copying ongoing assignment
problem - loop prints output twice
the problem s.nextint() command reads int value. when continue reading s.nextline() "\n" enter key. skip have add s.nextline(). hope should clear now.
try that:
system.out.print("insert number: "); int number = input.nextint(); input.nextline(); // line have add (it consumes \n character) system.out.print("text1: "); string text1 = input.nextline(); system.out.print("text2: "); string text2 = input.nextline();
Comments
Post a Comment