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 trialDaniel Silva
5,353 PointsIncompatible Types
When I compile the program I get an error message
Treet treets = new Treet[0];
^
./com/teamtreehouse/Treets.java:24: error: incompatible types: Treet[] cannot be converted to Treet
treets = (Treet[]) ois.readObject();
^
./com/teamtreehouse/Treets.java:32: error: incompatible types: Treet cannot be converted to Treet[]
return treets;
I'm sure I have everything right. Here is what the main class looks like
Treet[] reloadedTreets = Treets.load();
for(Treet reloaded : reloadedTreets){
System.out.println(reloaded);
}
1 Answer
Seth Kroger
56,413 PointsYou seem to be mixing up whether treets
should be a single Treet or an array of Treets (i.e., Treet[]
). Given the plural, you probably want the latter.
Daniel Silva
5,353 PointsDaniel Silva
5,353 PointsNever mind, I've figured it out.
Thanks,