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 IO

How do i use console.printf to display a message that says, "First name: "?

In challenge 3/4 it tells me to use the "console.printf" to print my name using" %s" and the "firstName" from the "String." so I used this-- console.printf("%s is amazin", firstName);-- and it tells me to ensure that i am using the format of "firstName" even tho i am using it.

Am I doing something wrong?

IO.java
String firstName = "jacob";
console.readLine ("%s is cool", firstName);
String lastName = "matthews";
console.readLine ("%s is cool", lastName);
console.printf("%s is amazin", firstName);

1 Answer

You didn't put your readLine in your Strings, your printf is suppost to print out your name and last name using %s.

String firstName = console.readLine("What is your first name: ");
String lastName = console.readLine("What is your last name: ");
console.printf("First name: %s", firstName);
console.printf("Last Name %s", lastName);