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

I have an error below: ........., Can someone please help me?

Error: Example.java:8: error: illegal start of type
System.out.printf("This is a new Treet: %s %n", treet);
^
Example.java:8: error: <identifier> expected
System.out.printf("This is a new Treet: %s %n", treet);
^
4 errors

My Code:

Example.java class:

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

public class Example{

public static void main(String[] args) Treet treet = new Treet("Charles Hopkins","Welcome, to my blog.",new Date(1501281553L)); System.out.printf("This is a new Treet: %s %n", treet); }

Treet.java class:

package com.treehouse;

import java.util.Date;

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

1 Answer

Chris Tvedt
Chris Tvedt
3,795 Points

You are missing a "{" after "main(String[] args)".

Also, it looks like you have imported a class inside your main method.

Also you are declaring your package inside the main method.

And why is "Treet.java class:" even in there?

If you imbed your code to the forum it makes it more readable and easier for others to help you out. click "Markdown Cheatsheet" underneath the window you are typing in to see how you imbed code.

Please check this question as answered if this fixes your error.

Chris

Can you help me because I don't know how to embed the code?

Nevermind, but thanks. I figured it all out.