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

San Francisco
San Francisco
28,373 Points

Need Halp

Not sure why I'm getting this error...this is for Java Data Structures Challenge Task 1 of three in the section "Getting There"

Here is the error message below:

./com/example/BlogPost.java:3: error: class, interface, or enum expected package com.example; ^ JavaTester.java:52: error: cannot access BlogPost Field[] fields = BlogPost.class.getDeclaredFields(); ^ bad source file: ./com/example/BlogPost.java file does not contain class com.example.BlogPost Please remove or make sure it appears in the correct subdirectory of the sourcepath. 2 errors

com/example/BlogPost.java
import java.util.Date;

package com.example;

public class BlogPost {

  private String mAuthor;
  private String mTitle;
  private String mBody;
  private String mCategory;
  private String mCreationDate;

}

2 Answers

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Try adding your import statement after the package declaration, but before the class declaration.

After you've changed that, you may get a different error... your mCreationDate member variable should not be a String, but a Date.