I have a for loop that is entered if the user chooses so.
System.out.println("Single Player=1\t Two Player=2\t Report Single
Tables=3\t Report all tables=4\t Exit=5");
choice= sc.nextInt();
if(choice ==1){
for (int i = 0; i <= np.length; i++) {
if (np[i] == 0) {
np[i]++;
System.out.print("Enter name:");
String str = sc.nextLine();
player1[i] = str;
break;
}
}}
When i enter the for loop, the enter name prompt pops up as well as the menu again, which is supposed to appear after the loop finishes. What i am confused about is why it is breaking before i can even enter the name.