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
ruben contesti
1,279 Pointserror: cannot find symbol
package com.example;
import java.util.Date;
public class BlogPost implements Comparable {
private String mAuthor;
private String mTitle;
private String mBody;
private String mCategory;
private Date mCreationDate;
public int compareTo (Object obj){
if(equal(com.example.BlogPost)){
com.example.BlogPost other =(com.example.BlogPost) obj;
return 0;
}
return 1;
}
public BlogPost(String author, String title, String body, String category, Date creationDate) {
mAuthor = author;
mTitle = title;
mBody = body;
mCategory = category;
mCreationDate = creationDate;
}
public String[] getWords() {
return mBody.split("\\s+");
}
public String getAuthor() {
return mAuthor;
}
public String getTitle() {
return mTitle;
}
public String getBody() {
return mBody;
}
public String getCategory() {
return mCategory;
}
public Date getCreationDate() {
return mCreationDate;
}
}
3 Answers
Kristian Terziev
28,449 PointsNo no no no no no no no. Please find a way to structure that code and post your error. You'll never get help like that.
ruben contesti
1,279 PointsHi Kristian, I'm dealing with the question here . Is there any way to delete this question so as not to duplicate it. Sorry for the inconveniences caused.
Kristian Terziev
28,449 PointsTry using "BlogPost" only. Without the package. You have that in two places in your code. See if it works.
ruben contesti
1,279 PointsOk. I already solved it. The error was what I was comparing. It should be the obj not BlogPost
ruben contesti
1,279 Pointsruben contesti
1,279 PointsHi, Kristian. Thank you for your comment. I have just corrected my post.
Kristian Terziev
28,449 PointsKristian Terziev
28,449 PointsThat was a good first step. Now please include the error you get. Not just "cannot find symbol" but the whole line. So that way we know where to look.