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 Getting There Class Review

class review java data structures alot of errors!!

I was doing the excercise and at the end ive got 20 errors!!

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, string Date creationDate){
   mAuthor = author;
   mDescription = description;
   mCreationDate = creationDate;


  }

  public String getAuthor() {
   return mAuthor;

  }

  public String getDescription(){
    return mDescription;

  }

  public Date getCreationDate() {
   return mCreationDate; 

  }

example.java

import com.teamtreehouse.Treet;

public class Example {

public static void main(String[] args) {
    Treet treet = new Treet(
    "Chris",
    "Want to be famous? Simply tweet about java and use" +
     "the hashtag #treet. I'll use your tweet in a new" +
      "@treehouse course about data structures.",
    new Date(1421849732000L)
    );
  System.out.printf("This is a new Treet %s %n", treet);
}  

}

1 Answer

Jeff Wilton
Jeff Wilton
16,633 Points

I only saw 2 problems with Treet.java:

1) you had an extra "string" in your constructor parameter list:

public Treet(String author, String description, string Date creationDate){

2) you were missing a closing curly brace at the end of the file.

The resulting code looks like this:

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;
  }

  public String getAuthor() {
   return mAuthor;
  }

  public String getDescription(){
    return mDescription;
  }

  public Date getCreationDate() {
   return mCreationDate; 
  }

}

In Example.java you were just missing the Date import:

import com.teamtreehouse.Treet;
import java.util.Date;

public class Example {

public static void main(String[] args) {
    Treet treet = new Treet(
    "Chris",
    "Want to be famous? Simply tweet about java and use" +
     "the hashtag #treet. I'll use your tweet in a new" +
      "@treehouse course about data structures.",
    new Date(1421849732000L)
    );
  System.out.printf("This is a new Treet %s %n", treet);
}  

}