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

Vidit Shah
Vidit Shah
6,037 Points

Compile Error in BlogPost task

my code import com.example.Blogpost;

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

} }

compile error

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

  }
}

3 Answers

Aha!!

import com.example.Blogpost; // wrong class name!

You need a capital P in this!!

Steve.

Vidit Shah
Vidit Shah
6,037 Points

Thank you so much sir :) Stupid me!!!

It took me too long to spot that! Glad to have got it sorted. :+1:

Hi Vidit,

I think the compiler must have had a glitch; your code works fine for me. Try it again.

Steve.

Vidit Shah
Vidit Shah
6,037 Points

./Display.java:1: error: cannot find symbol import com.example.Blogpost; ^ symbol: class Blogpost location: package com.example ./Display.java:6: error: cannot find symbol BlogPost post=new BlogPost(); ^ symbol: class BlogPost location: class Display ./Display.java:6: error: cannot find symbol BlogPost post=new BlogPost(); ^ symbol: class BlogPost location: class Display 3 errors

It shows me following errors but can't understand.

I don't understand this ... here's my code that passes:

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

I've tried your code too, and it worked fine. Let me see if I can replicate the issue you're seeing. Maybe the spacing around post = new is to blame.

Steve.

I have replicated your error ... no to fix it! (And it isn't the spacing).