I am trying to write to code to list all the objects in the class. (Which is working) but I want to get the code to check if there are objects if the player is empty and print out a message to screen if it is. But I cant get it to work. Can anyone assist me please ?
Class
public void listAll()
{
for (Song a : songs) {
if(songs.isEmpty()) //cant get this to check if there are songs on the player.
{
System.out.print("There are no songs on the playlist");
}
else{
System.out.print(a);
}
}
}
Tester
keyIn.nextLine(); //clear the buffer of the previous option
System.out.print("On player are");
player.listAll();
break;
enhanced for loop. Loop willl automatically terminate when the next element in array is null.