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 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,512 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