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

Differences stile to compare

Hello, Look at this two methods should it be correct by changing some places???

@Override
  public int compareTo(Object obj){
    Treet other = (Treet) obj;
    if (equals(other)){
        return 0; 
    }
    int dateCmp = mCreationDate.compareTo(other.mCreationDate);

      if(dateCmp == 0){
        return mDescription.compareTo(other.mDescription); 
      }
    return dateCmp;
  }

1 Answer

Hi Araz,

In your code above you are calling compareTo inside itself. That's not going to go well!

What challenge, or course, are you trying to get through here? I'll take a look and see what we can figure out.

Steve.

Hello Steve, Thank you! its about data Structures the comparable exercize but i did it! so its okey!