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

Isam Al-Abbasi
Isam Al-Abbasi
2,058 Points

Help with task 3 please!!

Using the console's printf method, display a message that says, "First name: ", followed by the first name that the user has entered.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("Isam"); 
String lastName = console.readLine("Al-Abbasi");
console.printf("First name:  "), firstName;

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

There are a few things going on here. First, it's not necessary to send in strings at the readLine. That can be done at runtime. Secondly you've omitted the %s from your string formating. Third, your close parentheses is misplaced on that line. Take a look:

String firstName = console.readLine(); 
String lastName = console.readLine();
console.printf("First name:  %s", firstName);
Isam Al-Abbasi
Isam Al-Abbasi
2,058 Points

haha I'm glad that I've joined this community, good luck for both of us :)

Isam Al-Abbasi
Isam Al-Abbasi
2,058 Points

Thank you so much Jennifer, I just started to learn programming like 3 days ago so things are started to get harder :D Good thing that I have people like you who can help me in this journey :)

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hey, you and me both! I can't tell you how many times people on the forums have helped me out :) I love this community!