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

Class Review Video Error

I can't figure out what is wrong with my code. this is the same code he uses in the video:

import com.teamtreehouse.Treet;

import java.util.Date;

public class Example{

public static void main(String[] args){ Treet treet = new Treet( "Not your business", "Zaphod Beeblebrox is awesome, no question", new Date(1465829029L) ); System.out.printf("This is a new Treet: %s %n", treet); }

What is the error you are getting?

This is the error code I'm getting: Example.java:11: error: incompatible types: Date cannot be converted to String
new Date(1465829029L)
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

Could you post the Treet class? It sounds like the Treet object is thinking that the Date object is meant to be a String. Or could you tell me which lesson this is from? Then I can go to it and try it myself.

some similar looking code at https://teamtreehouse.com/community/examplejava-code and you may be missing a closing }

1 Answer

I copied your code into the workspace added the } at the end and recompiled.

treehouse:~/workspace$ javac Example.java                                              
treehouse:~/workspace$ java  Example                                                   
This is a new Treet: Treet:  "Zaphod Beeblebrox is awesome, no question" - @Not your bu
siness                                                                                 
treehouse:~/workspace$