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
Anthony Branze
4,887 PointsStuck 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; }
2 Answers
Anthony Branze
4,887 PointsI 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
Treehouse TeacherYou need to compare the dates between the current and the other
Anthony Branze
4,887 PointsIs comparing date between current and other covered in the video? I can't seem to figure it out.
Craig Dennis
Treehouse TeacherYes in the video at about 8:30.
Hope it helps!
Anthony Branze
4,887 PointsAnthony Branze
4,887 PointsAlso getting " expected -1 but got 1"