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
Huggins Tatenda Mafigu
7,091 PointsChallenge Task 1 of 1 Now that we know about Generics, let's upgrade our Comparable interface defined on the BlogPost c
This is my answer but i dont know where im going wrong pliz help
package com.example;
import java.io.Serializable; import java.util.Date;
public class BlogPost implements Comparable<BlogPost>, Serializable { private String mAuthor; private String mTitle; private String mBody; private String mCategory; private Date mCreationDate;
public int compareTo(BlogPost other) { //BlogPost other = (BlogPost) obj; if (equals(other)) { return 0; } return mCreationDate.compareTo(other.mCreationDate); } }
1 Answer
Blake Larson
13,014 PointsBlogPost other = (BlogPost) obj;
This line can be deleted because the interface is doing the typecasting for you. We already know that "other" is of type BlogPost.