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 trialVidit Shah
6,037 PointsCompile 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
package com.example;
public class BlogPost{
}
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
Steve Hunter
57,712 PointsAha!!
import com.example.Blogpost; // wrong class name!
You need a capital P
in this!!
Steve.
Steve Hunter
57,712 PointsHi Vidit,
I think the compiler must have had a glitch; your code works fine for me. Try it again.
Steve.
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.
Steve Hunter
57,712 PointsI don't understand this ... here's my code that passes:
package com.example;
public class BlogPost{
}
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.
Steve Hunter
57,712 PointsI have replicated your error ... no to fix it! (And it isn't the spacing).
Vidit Shah
6,037 PointsVidit Shah
6,037 PointsThank you so much sir :) Stupid me!!!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsIt took me too long to spot that! Glad to have got it sorted.