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 trialNick Ciancio
521 PointsQuiz asks to replace your name with the string formatter, won't take console.printf ("%s can code in Java!", firstName);
This looks like an obvious failure of the quiz to me. Either it decided to ask something I haven't learned, or it doesn't recognize correct code.
// I have setup a java.io.Console object for you named console
String firstName = "Nick";
console.printf ("%s can code in Java!", firstName);
1 Answer
andren
28,558 PointsWhile your code is indeed correct, it is a bit unusual. In Java (while technically valid) it is quite uncommon to place a space between a method's name and its parentheses.
Since it's rare the code checker for this challenge does not take that coding style into account, and therefore, as you state fail to recognize code that is technically correct.
If you remove the space like this:
String firstName = "Nick";
console.printf("%s can code in Java!", firstName);
Then your code will be recognized as correct.
Nick Ciancio
521 PointsNick Ciancio
521 PointsVery fast response, thank you. You're right, removing the space removed the problem. Interesting that syntax that is specifically for formatting can disrupt things, I would think the quiz should respond to the output.