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

Patrick Heflin
Patrick Heflin
6,281 Points

Challenge 2, Question 3 of Java Basics

Dose not make sense.

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

3 Answers

You're a step ahead! It wants exactly what the question says:

// I have setup a java.io.Console object for you named console
String firstName = "Steve";
console.printf("<YOUR NAME> can code in Java!");

No prizes for guessing what step 3 is!! ;-)

Steve.

Patrick Heflin
Patrick Heflin
6,281 Points

Hi! This was step 3. It was asking me to replace YOUR NAME in the console.printf expression with the firstName variable using the string formatter. Can you tell what I am doing wrong? Thanks!

It'll be the space after printf before the bracket. I just tried it to test that out.

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

In Challenge 2, question 2 is :

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

Question 3:

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

Patrick Heflin
Patrick Heflin
6,281 Points

It was the space after printf before the bracket. Thanks guys!