Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialedard stark
272 Pointswhy he used List<Song>
please explain me Thank you!
Simon Coates
28,694 PointsSimon Coates
28,694 PointsList is just an flexible sized ordered collection. It's very common for wanting to bundle multiple objects into a single variable and has more flexibility than an array. You can read List<Song> as "list of songs". Being an interface, it just defines the methods that the implementing classes (eg. ArrayList) needs to implement. The motivation for using the List over a concrete implementation is increased abstraction (helps with maintenance). The list defines the contract, and given that all lists have a minimal set of methods defined by the interface, you could plausibly replace the type of underlying implementation (maybe using a LinkedList over an ArrayList).
Song is a custom class used to bundle some data and behavior for ease of use and conceptual clarity.