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, Variables, and Formatting

what am i doing wrong

it says i need %s and i have it but it isnt showing up

Name.java
// I have setup a java.io.Console object for you named console
String firstName = ("Zack");
console.printf(" %S can code in java/n 
               , firstName");

2 Answers

You did a good job!

However, if you run this code and look in the Console, it will print " %S can code in java/n, firstName". All you need to do it fix that string. Here's the steps you must do to pass the challenge (just for your information code challenges are extremely picky!):

  • Get rid of the extra space in the beginning of the string (code challenges are super picky!)
  • You said "java", change that to "Java" (Java is super picky about cases! Lowercase and uppercase letters are different in Java)
  • And most importantly, you had the ", firstName" part of the string inside the string. In Java, it is required to put it outside and next to the string to make it another parameter.

Here's the complete code:

// I have setup a java.io.Console object for you named console
String firstName = "Zack";
console.printf("%S can code in Java/n", firstName);

Good luck!

Hope this helps, Alex

Thomas Nilsen
Thomas Nilsen
14,957 Points
String firstName = "Zack";
console.printf("%S can code in java", firstName);