Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Organizing Data Comparable

Demauri Portis
Demauri Portis
4,809 Points

[SOLVED]mCreationDate cannot find symbol

Alright, now let's order the blog post's creation date chronologically, oldest first.

NOTE: The app where this class is being used ensures that no two blog posts are posted at the same time, so you do not need to worry about any edge cases.

I've looked at other forum posts of this similar code but at different stages in the course. I've tried exactly what they've done but yet still can't pass the challenge. Not understanding why stuck.mCreationDate cannot find symbol when passed into the compareTo argument when I'm still within the class with the private field. Any suggestion? Maybe a different approach, doesn't necessarily say I have to return this information, just order it.

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 BlogPost(String author, String title, String body, String category, Date creationDate) {
    mAuthor = author;
    mTitle = title;
    mBody = body;
    mCategory = category;
    mCreationDate = creationDate;
  public int compareTo(Object other) {
    Object stuck = (BlogPost) other;
    if(equals(other)) {
      return 0;
    int dateCmp = mCreationDate.compareTo(stuck.mCreationDate);
    if (dateCmp == 0) {
       return dateCmp;
       return dateCmp;

  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;


2 Answers

Mind sharing how did you solve it?

13,229 Points

if you still hittin your head on the wall with this challenge, you might check this link: https://teamtreehouse.com/forum/how-do-i-do-this-15

Jordan George
Jordan George
9,926 Points

The other return statement isn't pointless. It is there if dateCmp doesn't equal 0.