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

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.