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 trial

Java Java Basics Getting Started with Java Strings and Variables

Cesar Daniel Gonzalez Estrada
Cesar Daniel Gonzalez Estrada
2,546 Points

Step 3 console.printf ("s% can code in Java!/n", firstName); What's wrong with my code?

String firstName = "Cesar";

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

What's wrong with my code?

3 Answers

It should be %s instead of s%

Also, \n instead of /n

Jakob Wozniak
Jakob Wozniak
17,896 Points

You need %s for the string and %n for the new line. Good luck!

abmsc86
abmsc86
4,949 Points

\n not %n for new line. :)

Jakob Wozniak
Jakob Wozniak
17,896 Points

Actually, %n is a command for System.getProperty("line.seperator"), and is more consistent than \n. The \n works, but it gives you a Unix style line ending, just like \r\n gives you a Windows line ending.

%n will always find the system's new line function, so it's a best practice for this.