Hey guys, I am trying to make a program that allows you to input music artist into an array. The array row length is dependent upon a number entered by the user. There are only three column. I am having trouble with a line inside the for loop printing twice in a row before recieving input for the array. However if I change the " int songs=keyboard.nextInt " to a " final songs=3 or any other number, the loop processes correctly. It seems to be an issue with the keyboard.nextint not reading correctly in the array I assume. Here is part of my code.
public class Music
{
public static void main(String[] args)
{
System.out.print("You may enter up to 20 songs. "+
"How many songs would you like to enter?");
Scanner keyboard=new Scanner(System.in);
int songInfo=3;
int songs=keyboard.nextInt();
String[][] music=new String[songs][songInfo];
System.out.println("Please, enter song title, artist, and album title.");
for(int row=0; row<songs; row++)
{
for(int col=0; col<songInfo; col++)
{
System.out.print("Enter inforomation.");
music[row][col]=keyboard.nextLine();
}
System.out.println();
}
The loop prints Enter Information. Enter Information. before it asks for an input for the first Enter Information. Any help would be appreciated. Just looking for a push in the right direction.