for loop skip issue

wofsereIntorn

New Member
I have this code, and everything is running as i want to except the face that it skips the first time it is supposed to wait for the next input by the user. Here is the code:\[code\]import java.util.Scanner;public class mainThread { public static int size; public static int counter; public static Scanner input = new Scanner(System.in); public static String currentIn; public static void main(String[] args){ System.out.println("Please type the desired amount of players: "); size = input.nextInt(); String nameArray[] = new String[size]; for(int counter = 0; counter < size; counter++){ System.out.println("Please enter the name of player " + (counter+1)); currentIn = input.nextLine(); nameArray[counter] = currentIn; System.out.println(nameArray[counter]); } }}\[/code\]Here is what the console says:\[code\]Please type the desired amount of players: 3Please enter the name of player 1Please enter the name of player 2JacobJacobPlease enter the name of player 3\[/code\]It completely skips the first loop, and i can't seem to figure out why. Thanks for your time!
 
Back
Top