Hey, everyone. I’m new to Java and I have 2D LinkedList like this:
LinkedList<LinkedList<String>> albums = new LinkedList<LinkedList<String>>();
Which is filled with data like so:
if (!artist.isEmpty() && !name.isEmpty()) { albums.add(new LinkedList<String>()); albums.getLast().add(artist.toString()); albums.getLast().add(name.toString()); }
But I want to make sure my list has no duplicate albums. How to check whenever my albums list already contains same pair of artist and name?
My suggestion would be to create a new class, called Album that looks something like this:
Then you should be able to use contains() to check whether or not the album already exists in the linked list.