I'm trying to do a foreach loop with an ArrayList... here's the story...
I have an ArrayList:
ArrayList<Album> coll = new ArrayList<Album>();
This contains information about a number of albums that make up a collection/library...
The Album class contains a method that returns the album name in string.
I'm basically trying to find out if album already exists or not with a foreach loop.
I have this method:
public Boolean findAlbumByName(ArrayList<Album> albumList, String name){
for (Album album : albumList)
{
if (album.getName().equals(name))
{
return true;
}
}
return false;
}
The problem occurs when I try to do this statement:
if(findAlbumByName(coll, 'example song') == false)
{
// code here
}
It has an error that reads: The method findAlbumByName(ArrayList<Album>, String) is undefined for the type Album.
Any help or clue would be highly appreciated. Thank you.