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

c++ - list<myClass<int> * > sort -

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

java - why am i getting a "cannot resolve method" error on getApplication? -