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

Peter Taylor
PLUS
Peter Taylor
Courses Plus Student 4,275 Points

Package BlogPost compiler error

I get a compiler error but the creation of the BlogPost object looks correct to me. Compiler error below.

./com/example/BlogPost.java:3: error: '{' expected public class BlogPost(){

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) {
    // Your code here...
    BlogPost blog = new BlogPost();
    System.out.printf("This is a blog post: %s", blog);

  }
}

1 Answer

Maybe try removing the () parentheses in this file:

package com.example;

public class BlogPost(){
}

If you remove them, I believe it should look like this:

package com.example;

public class BlogPost {
}

:point_right: Remember: You only use parentheses when calling/defining methods!

If this helped you out, please mark it as a Bets answer. Thank you!

~Alex