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

I Do not understand what i've done wrong i have printed %s\, firstName like i'm sopost to

i have printed %s\, firstName on the consul log

Name.java
// I have setup a java.io.Console object for you named console
%s\, firstName

2 Answers

Hey Aidan,

Is this all of your code for the challenge?

You should have something similar to this format:

String example = "Jacob";
console.printf("%s is awesome!", example);

Notice how I'm using the printf method and passing in a String and the variable name?

Ruben Simon
Ruben Simon
1,120 Points

Hi Aidan,

first initialize the variable that you shall call firstName as a String :

String firstName = "Aidan";

Then print it: %s is a place holder for the string (that's why it is %s) and after you finish the quote you have to tell the programme which String you want to use (=your first Name).

console.printf("%s is awesome", firstName);

So your solution is:

String firstName = "Aidan";

console.printf("%s is awesome", firstName);