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

Challenge Task 2 of 3, any example of good code, i try everything...tnx

snapshot of good code,i don t understand what i need to do. tnx

Name.java
// I have setup a java.io.Console object for you named console
String firstName="Andrej";
console.printf("Hello my name is %s\n," firstName);
console.printf("What is yourName\n," firstName);

1 Answer

The comma should be after the string, not in the string:

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

Best regards,

Philip

Philip, I could be wrong, but that second console.printf call doesn't seem to make sense. Is he supposed to be doing a console.readLine to get an answer back there? And if so, why is firstName the argument again? Could you check out that exercise and see what he's supposed to be doing?

Thanks Nicolas, you're right. I just took his Code and implemented the changes, because I thought the prompt will be done next task. I checked out the challenge before, but thought it is randomly generated.