Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

Name.java
// 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

andren
andren
28,520 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!