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!
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
Peter Taylor
Courses Plus Student 4,275 PointsPackage 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(){
package com.example;
public class BlogPost(){
}
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

Alexander Davison
65,468 PointsMaybe 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 {
}
Remember: You only use parentheses when calling/defining methods!
If this helped you out, please mark it as a Bets answer. Thank you!
~Alex