here is my simple question:... How can I eliminate the 'nextline' after a scanner output?
System.out.println("Player 1: Rock (1), Paper (2) or Scissors?(3)");
int p1 = input.nextInt();
if (p1 == 1) {
System.out.print("= rock\n");
} else if (p1 == 2) {
System.out.print("= paper\n");
} else {
System.out.print("= scissors\n");
}
outcome:
Player 1: Rock (1), Paper (2) or Scissors?(3)
1
= rock
desired outcome
Player 1: Rock (1), Paper (2) or Scissors?(3)
1 = rock
Thanks to you all