H
Honyin Hau
Please help, have to hand in 2 hours time....
I don't understand what the error message means and how to change it
Thanks million in advance
Error message selecting the first for(Song s : list): foreach not applicable
to expression type
Code:
public boolean merge(SongList list) throws NullPointerException
{
ArrayList<Song> playlist2 = playlist;
boolean testing = true;
for(Song s : list)
if(!playlist2.add(s)) // in case if add has error, it will not
change playlist
testing = false;
if(testing==false) throw new NullPointerException("Error in:
merge");
for(Song s : list)
playlist.add(s);
return true;
}
I don't understand what the error message means and how to change it
Thanks million in advance
Error message selecting the first for(Song s : list): foreach not applicable
to expression type
Code:
public boolean merge(SongList list) throws NullPointerException
{
ArrayList<Song> playlist2 = playlist;
boolean testing = true;
for(Song s : list)
if(!playlist2.add(s)) // in case if add has error, it will not
change playlist
testing = false;
if(testing==false) throw new NullPointerException("Error in:
merge");
for(Song s : list)
playlist.add(s);
return true;
}