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

Amit Dhamankar
Amit Dhamankar
4,163 Points

I am Showing you these 2 classes code, from Data Structures videos but the program is not working. why?

import java.util.Date;

import com.teamtreehouse.Treet;

public class Example {

public static void main(String[] args) { Treet treet = new Treet( "amitDhamankar", "Want to be famous? Simply tweet about Java and use" + " the hashtag #treet. I'll use yout tweet in a new" + "@treehouse code at data structures.", new Date(1468901376000L )); System.out.printf("This is a new Treet: %s \n",treet);

} }

And the other class is: package com.teamtreehouse;

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

}

Ante Adamović
seal-mask
.a{fill-rule:evenodd;}techdegree
Ante Adamović
Front End Web Development Techdegree Student 2,508 Points

It would be nice if you could wrap it in a code using ```java, check 'Markdown Cheatsheet' for reference

public class Example {

}

Also what's the error message you're getting ?

Based off of what you posted in the Treet.java class you are missing the import java.util.Date; If it is not declated the mCreationDate variable will not work and also the getCreationDate() method.

1 Answer

just import java.utils.Date and it will be fine