Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Getting There Packages

BlogPost.java final challenge giving error

I am getting an error on the final challenge while creating the new instance of BlogPost and writing out using System.out.printf. I believe the code is correct so do not understand why it won't pass the challenge.

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

public class BlogPost(){
}
Display.java
import com.example.BlogPost;

public class Display {
  public static void main(String[] args) {
    BlogPost blogPost = new BlogPost();
    System.out.printf("This is a blog post: %s",blogPost);

  }
}

3 Answers

The only thing I see that's wrong with your code is in the definition of the BlogPost class. When declaring the class, you have parenthesis after the class name which shouldn't be there.

Michael Hess
Michael Hess
24,511 Points

Hi Chris,

As Alexander pointed out there are parentheses after the BlogPost class name which should be removed. But, other then that, I see no other reasons why your code shouldn't pass -- it looks like you've got it. The following code has been used to pass the final part of this challenge -- feel free to use it.

import com.example.BlogPost;

public class Display {
  public static void main(String[] args) {
    // Your code here...
    BlogPost blogPost = new BlogPost();
    System.out.printf("This is a blog post: %s", blogPost);

  }
}
package com.example;

public class BlogPost {
}

Hope this helps!

Thanks all, I was able complete by removing the brackets