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 Packages

Java Data Structures- Packages- challenge 4 of 4 I'm not sure what I'm doing wrong in this step

I've googled this question, but I can't find any answers more recent than 2015. I don't know what I'm doing incorrectly, but I am still returning 4 Syntax errors

com/example/BlogPost.java
package com.example;
class BlogPost {

}
Display.java
public class Display {
  public static void main(String[] args) {
    // Your code here...
import com.example.BlogPost
  BlogPost Blogpost = new BlogPost();
    System.out.printf("This is a blog post: %s", BlogPost);
  }
}
David Pollard
David Pollard
4,324 Points

Hi there

I'm also learning Java and recently completed the BlogPost stuff. Could you post the errors that result ?

I think the import line should be before the very first line, although that may be more "good form" than a requirement.

Also, I think BlogPost needed to be called with some values if my memory is correct, something on the lines of :-

BlogPost blogpost = new BlogPost("Author Name", "Description", new Date());

But the errors will be very helpful to know what's going wrong !

hth

dp

1 Answer

Steven Parker
Steven Parker
231,268 Points

Here's a few issues I spotted:

  • the declaration of the BlogPost class needs "public" access to be used in the other module
  • the "import" statement should come first in the file
  • the "import" statement needs a semicolon at the end
  • a different name for the new BlogPost object would prevent confusion with the class itself

Also, it sounds like Google may not be the best way to peruse forum history. But the "breadcrumbs" at the top of the question make it easy to look at other questions on the same issue, newest first by default.