Java Java Data Structures Getting There Packages

Tojo Alex
PRO
Tojo Alex
Pro Student 13,331 Points

Task 4 of 4

Where did I go wrong?

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

public class BlogPost {
}  
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);

  }
}

2 Answers

Cam Richardson
MOD
Cam Richardson
Front End Web Development Treehouse Moderator 16,882 Points

It may be because you're defining the BlogPost class twice. The java compiler really doesn't like it when you define a class more than once:

./com/example/BlogPost.java:5: error: duplicate class: com.example.BlogPost
public class BlogPost {
       ^
1 error

So you just need to take out the second class definition for BlogPost in com/example/BlogPost.java. Hope that helps!