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 trialAndre Kucharzyk
4,479 PointsThis might be a dumb question, but how do we know what kind of objects interface can take?
This might be a dumb question, but how do we know what kind of objects interface can take?
private List<Song> songs; <-- how do we know that we can put Songs there?
Andre Kucharzyk
4,479 PointsI guess my question is why can we put any object in List/Map/Set? Where in code is that determined?
Yanuar Prakoso
15,196 PointsYanuar Prakoso
15,196 PointsFirst it will be better if you refine your question to be What kind of objects does a List, Set, Map interface can take? You need to be specific here since interface has broad definition.
The answer is theoretically if it is an object it can be put in List, Map, and/or Set.