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 Object Inheritance

i get error when trying to run code from video i dont see what is wrong

i get this error when trying to run the code. I keep comparing code but dont see whats wrong.

Error: pubpackage com.teamtreehouse;
^
Example.java:2: error: cannot access Treet
import com.teamtreehouse.Treet;
^
bad source file: ./com/teamtreehouse/Treet.java
file does not contain class com.teamtreehouse.Treet
Please remove or make sure it appears in the correct subdirectory of the sourcepath.

-------my code is below

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

}

@Override public String toString(){ return "Treet: \"" + mDescription + "\" - @" + mAuthor;

}

public String getAuthor() { return mAuthor; }

public String getDescription(){ return mDescription; }

public Date getCreationDate(){ return mCreationDate; }

}

3 Answers

The first line of your code should just say "package..." not "pubpackage..."

That should fix it.

Marco,

A few things to clarify first

  • pubpackage com.teamtreehouse; ---- why did you use the pubpackage here?
  • file does not contain class com.teamtreehouse.Treet ----- are you sure you've stored the file in the correct folder structure ?
biruk mandefro
biruk mandefro
1,870 Points

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

change you package declaration.