Java Java Data Structures Efficiency! Queueing

Manh Truong Nguyen
Manh Truong Nguyen
2,021 Points

i dont understanding this line of code plz help

in this video at 10:51 he wrote List<String> artists = new ArrayList<>(mSongBook.getArtists()); i dont understanding why he puts mSongBook.getArtists() in that bracket of Arraylist? cuz normally he just left it blank

2 Answers

Brendon Butler
Brendon Butler
4,235 Points

Erik was correct. You can create an empty list by leaving it blank and adding in values later.

If you already have some sort of Collections that contains data, you can input that into the parenthesis to fill your new list.

Erik Gabor
Erik Gabor
3,942 Points

It really reminds me of C# generics

List<int> numbers =new List<int>();

I don't know Java. But my hunch is it inializes a list of strings