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 trialIsrael Palma
1,456 PointsBug in the BlogPost exercise for the Java Data Structures section
Hi it seems to be a bug here since I am giving the right answers and I also noticed the name of the java file for the BlogPost class contains illegal simbols....
Is this correct or what am I doing wrong?
4 Answers
Steve Hunter
57,712 PointsDelete the word Java from your import. You only want to import com.example.BlogPost
Steve.
Steve Hunter
57,712 PointsHi Israel,
What characters/illegal symbols are you seeing?
The Display file should end up looking like this:
import com.example.BlogPost;
public class Display {
public static void main(String[] args) {
// Your code here...
BlogPost blogPost = new BlogPost();
System.out.printf("This is a blog post: %s", blogPost);
}
}
The BlogPost
file looks like:
package com.example;
public class BlogPost{
}
Steve.
Israel Palma
1,456 PointsHello Steve and thanks.
The file for the BologPost java class (BlogPost.java) has the package path as the file name and so when I hit submmit it gives me an error but my code is correct just as what you've just posted here. So I guess it has to do with the name of the file since it does not match the name of the constructor or the class in the code. I get the error that the object BlogPost is not found, this is what makes me think that it is this what is causing the problem.
Steve Hunter
57,712 PointsHi Israel,
The path name is needed there as that's what makes the package statement work. That's not causing you an error.
Can you copy/paste your code, please. And let me know what any errors are saying.
Steve.
Israel Palma
1,456 Pointscom/example/BlogPost.java Display.java
This above are the two files my exercise's project shows... Now if I try to write the name as it appears in the file name it doesn't allow me to...
Israel Palma
1,456 PointsSure let me write it again since the page has refreshed.. one sec
Steve Hunter
57,712 PointsThose paths are correct, yes.
That defines the package name as com.example.BlogPost.
Israel Palma
1,456 PointsThis is my code:
import com.example.BlogPost.java;
public class Display { public static void main(String[] args) { // Your code here... BlogPost blogPost = new BlogPost(); System.out.printf("This is a blogpost: %s", blogPost);
} }
And... this is the error it throws in the command line
/Display.java:1: error: cannot find symbol import com.example.BlogPost.java; ^ symbol: class java location: class BlogPost ./Display.java:6: error: cannot find symbol BlogPost blogPost = new BlogPost(); ^ symbol: class BlogPost location: class Display ./Display.java:6: error: cannot find symbol BlogPost blogPost = new BlogPost(); ^ symbol: class BlogPost location: class Display 3 errors
Israel Palma
1,456 PointsSorry let me try to format this better...
Steve Hunter
57,712 PointsI think I've highlighted the issue. Give that a go and let me know how you get on.
Steve.
Israel Palma
1,456 PointsIsrael Palma
1,456 PointsOh! ok haha thanks
Israel Palma
1,456 PointsIsrael Palma
1,456 PointsYes this worked. But now maybe it is a good idead that the previous excercise (3/4) marks the import estatement incorrect when we add the .java part. It gave me a correct score... Thanks a lot !