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 trialAnas Ahmad
432 PointsFill in the blank to create an Array that can contain both Wine and Cheese:
public class Main {
public static void main(String[] args) {
Wine wine = new Wine();
Cheese cheese = new Cheese();
--Object[]--- foods = {wine, cheese};
}
}
class Wine implements Drinkable, Delicious {
//omitted
}
class Cheese extends Dairy implements Delicious {
// omitted
}
3 Answers
Steven Parker
231,275 PointsYou're close, but instead of "Object", look at the other classes that both of these either extend or implement.
Do they have something in common?
Simbarashe Mazambani
1,998 PointsDelicious[ ]
yige yang
8,329 Pointswhy is Delicious[] working??? I tried other similar words, but they didn't work.
Steven Parker
231,275 PointsBecause that's the only thing implemented by both "Cheese" and "Wine".
RafaΕ Stasiak
3,763 PointsAnd what is correct answer?