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

OMAR ANDERSON
PLUS
OMAR ANDERSON
Courses Plus Student 68 Points

ensure you put %s

need help

IO.java
String firstName ="Craig";

console.readLine("firstName");

String lastName ="Craig";

console.readLine("lastName");

console.printf("First name,Craig:",firstName);

3 Answers

Kjetil Lorentzen
Kjetil Lorentzen
13,360 Points

Hi Omar, In order to use printf() and write formatted output you need to use %s for attaching string variables to the output.

Check out: https://www.cs.colostate.edu/~cs160/.Spring16/resources/Java_printf_method_quick_reference.pdf or https://docs.oracle.com/javase/tutorial/java/data/numberformat.html.

For this particular challenge

String firstName = console.readLine();
String lastName = console.readLine();
console.printf("First name: %s", firstName);
console.printf("Last name: %s",lastName);
OMAR ANDERSON
PLUS
OMAR ANDERSON
Courses Plus Student 68 Points

thank you for responding, but i did all that and im still getting this error "Bummer! Did you forget to pass the firstName parameter to the printf function?"

OMAR ANDERSON
PLUS
OMAR ANDERSON
Courses Plus Student 68 Points

String firstName ="Omar"; console.readLine(firstName);

String lastName ="brown"; console.readLine(lastName); console.printf("First name:%s\n" ,firstName); console.printf("Last name: %s", lastName);