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 trialJan Lundeen
5,886 PointsCorrected quotes on Challenge Task 2 of 3 for Java Basics, strings and variables. Still getting compiler errors
Hi,
I corrected my quotes, but I'm still receiving compiler errors: Here's my code: String firstName = "Jan"; console printf ("Jan can code java!/n"); javac Name.java java Name
I'm not sure why I'm still seeing compiler errors. Any ideas?
Thanks,
Jan
String firstName = "Jan";
console printf ("Jan can code Java!/n")
javac Name.java
java Name
// I have setup a java.io.Console object for you named console
7 Answers
Steven Parker
231,184 PointsIt looks like there's a few issues:
- the 2nd line is missing a semicolon at the end
- there should be a membership operator (".") between "console" and "printf"
- for task 2, the challenge wants you to literally put "<YOUR NAME> can code in Java!" as the message
- you don't need a newline after the message (and a newline is "\n" instead of "/n")
- the third and fourth lines are compile and run commands and should not be in the source file.
Jan Lundeen
5,886 PointsHi Steven,
Your right. Gosh, I missed that the 2nd line is missing a semicolon. Thanks for the catch! Guess I've been staring at my code too long. :)
So I don't need the compile and run commands?
Thanks.
Jan
Steven Parker
231,184 PointsYou use the commands in the command window when working in the Workspace, but you don't put them in the code file.
For a challenge you don't need them, it does the compiling for you.
Jan Lundeen
5,886 PointsI only see one window. It sounds like the command window is separate from the window where I enter my code. Where is the command window?
Thanks,
Jan
Steven Parker
231,184 PointsMaybe "Console pane" is a better term, but that's only for the Workspace.
Jan Lundeen
5,886 PointsI don't see a separate tab on the code editor window, just the name of the file(Name.java). Where is the "View" menu for "Show Console". I tried to make a screenshot of what I'm seeing (using Alt-PrintScreen), but I can't paste it (using Control-V) to my answer.
Jan Lundeen
5,886 PointsAfter I added my code [e.g. String firstName = "Jan"; console printf ("Jan can code Java!/n"); ], I followed my code with the commands javac Name.java and Java Name. Then, I clicked the "Check Work" button. When I started the challenge, I noticed the comment below:
// I have setup a java.io.Console object for you named console
So I thought that I didn't have to do any other setup. I also looked at my workspace, but I think that's something separate from this. However, I did notice separate tabs (including one titled "View").
I looked at the comments in the String and Variables section from other students. It seems like there were lots of issues with Workspaces, but nothing that would answer the issue I'm experiencing.
Thanks,
Jan
Steven Parker
231,184 PointsI accidentally confused things with workspace references, they don't apply to the challenge.
I revised my original answer with a more complete issues list, see if that helps.
Jan Lundeen
5,886 PointsNo worries. I didn't know that's what they were asking for. That worked. Thanks!
Jan
Jan Lundeen
5,886 PointsSorry about that. i corrected the Best Answer. Not sure what happened.