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 trial

Java

Stuck and I don't know what this challenge wants Java data structure, organizing data, comparable, challenge 3 of 3.

This is in regard to the Java data structure course in the Comparable section and challenge 3 of 3 "Order the blog post's creation date chronologically. There was a previous question but Craig's answer didn't really make alot of sense to me, Here is my compare method:

public int compareTo(Object obj) {
 BlogPost other = (BlogPost) obj;
 if (equals(other)) {
return 0;
}
 return 1; }

Also getting " expected -1 but got 1"

2 Answers

I got it, Thank you Craig, You need to compare dates between current and the other with the ".compareTo" method

return mCreationDate.compareTo(other.mCreationDate);
Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

You need to compare the dates between the current and the other

Is comparing date between current and other covered in the video? I can't seem to figure it out.

Craig Dennis
Craig Dennis
Treehouse Teacher

Yes in the video at about 8:30.

Hope it helps!