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

Java Java Data Structures Getting There Object Inheritance

Sean Flanagan
Sean Flanagan
33,235 Points

My code is still not right but I don't know why

Hi. Can anyone help me with this please?

Example.java:

import java.util.Date;

import com.teamtreehouse.Treet;

public class Example {
  public static void main(String []args) {
    Treet treet = new Treet(
      "craigsdennis",
      "Feeling overwhelmed by learning to #code?" + 
      "Try out this thought hack I whipped up:  http://buff.ly/1LjAZrJ  #development #webdev",
      new Date(1437084178)
    );
    System.out.printf("This is a new Treet: %s %n", treet);
  }
}

Treet.java:

package com.teamtreehouse;

import java.util.Date;

public class Treet {
  private String mAuthor;
  private String mDescription;
  private Date mCreationDate;

  public Treet(String author, String description, Date creationDate) {
    mAuthor = author;
    mDescription = description;
    mCreationDate = creationDate;
  }
  @Override
  public String toString() {
    return "Treet: \"" + mDescription + "\" - @" + mAuthor;
  }

  public String getAuthor() {
    return mAuthor;
  }

  public String getDescription() {
    return mDescription;
  }

  public Date getCreationDate() {
    return mCreationDate;
  }
}

Error message:

Example.java:3: error: cannot find symbol                                                        
import com.teamtreehouse.Treet;                                                                  
                        ^                                                                        
  symbol:   class Treet                                                                          
  location: package com.teamtreehouse                                                            
Example.java:7: error: cannot find symbol                                                        
    Treet treet = new Treet(                                                                     
    ^                                                                                            
  symbol:   class Treet                                                                          
  location: class Example                                                                        
Example.java:7: error: cannot find symbol                                                        
    Treet treet = new Treet(                                                                     
                      ^                                                                          
  symbol:   class Treet                                                                          
  location: class Example                                                                        
3 errors  

Snapshot:

https://w.trhou.se/nbtpofm4m8

I've forked it also.

Thanks in advance.

Sean

2 Answers

Christopher Augg
Christopher Augg
21,223 Points

Hello Sean,

Did you notice that the name of your treet.java file is not the same as your constructor Treet() ?

Rename the treet.java file to Treet.java and it solves the issue.

Regards,

Chris

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Chris. I've renamed the file to your suggestion. Thanks for your help. :-)

Christopher Augg
Christopher Augg
21,223 Points

No problem Sean. Always glad to help.