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!

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 trial

Java Java Basics Getting Started with Java Strings, Variables, and Formatting

String firstName = "Rasmus"; console.printf ("%s can code in Java!", firstName); Why can't I pass?

It tells me that I have I need to leave the printf-statement intact?

// I have setup a java.io.Console object for you named console

String firstName = "Rasmus";

console.printf ("%s can code in Java!", firstName);

I tried the same code as you and it worked, perhaps try refreshing the page.

Me too, same problem.. can't get the last one... any help?

1 Answer

28,554 Points

The code checker for these challenges can be very picky, not just about the result of your code but the way the code is actually written as well. Due to the way the test for the last task is written it only accepts your code if there is no space between the method and its parenthesis. Like this:

String firstName = "Rasmus";
console.printf("%s can code in Java!", firstName);

While having a space between them is valid in Java it is pretty rare. It's far more common to format the code like shown above, which is why the code checker expects the code to look like that.

I ended up copying the code from the teacher, which worked perfectly. Thanks for the answer. I had a feeling it was a minor mistake like a redundant space!