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 trialAmanda Pace
752 PointsDo I need to be typing in the imports and public class info into the challenges? Or is there something else wrong?
Getting an error message despite the fact my challenge code looks just like the workspace code. Any ideas?
// I have setup a java.io.Console object for you named console
String firstName = "Amanda";
console.printf("%s can code in Java!, firstName");
1 Answer
Tom Bukowski
4,458 PointsI looks like you figured it out, but it wasn't due to the extra space between the comma and the variable firstName.
If you compare your first correction: console.printf("%s can code in Java!," firstName);
with what was correct: console.printf("%s can code in Java!",firstName);
You can work out what the error was trying to say "illegal start of expression console.printf("My name is %s" firstName);" which is that it was looking for the comma to separate the string and the variable. In your first correction the comma was inside the quotes, and the correct one had it outside.
Hope this helps.
Amanda Pace
752 PointsAmanda Pace
752 Pointsconsole.printf("%s can code in Java!," firstName);
I updated my code so the "" is not around firstName and am now getting this error > JavaTester.java:74: error: illegal start of expression console.printf("My name is %s" firstName);
console.printf("%s can code in Java!",firstName); i had an extra space between , and firstName