Java Java Data Structures Getting There Packages

M Spalding
M Spalding
12,336 Points

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

package com.example;
class BlogPost {

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 !



1 Answer

Steven Parker
Steven Parker
200,758 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.