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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -