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

what is my fault Print out to the screen using the printf method on console, "First name: " and the user's first name.

Print out to the screen using the printf method on console, "First name: " and the user's first name

Bummer! There is a compiler error. Please click on preview to view your syntax errors! Preview Recheck work IO.java

1 // I have imported java.io.Console for you. It is a variable called console. 2 String firstName = console.readLine("first name"); 3 String lastName = console.readLine("last name"); 4 console.printf("%s", firstname); 5 ā€‹ 6 ā€‹

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("first name");
String lastName = console.readLine("last name");
console.printf("%s", firstname);

3 Answers

Hey ebrahem anwar,

When you're doing challenges, be sure to do exactly as the challenge tells you to do. You don't have the proper variable nor the proper string in the "printf" line. The challenge tells you to print "First name: " and then the user's first name. The print line should be:

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

thanks a lot..... your rapid answer makes me so happy

My pleasure, ebrahem! There are a bunch of helpful fellow students on the forums who are always willing to help, so don't hesitate to ask a question if you have one. Cheers!

Hi Anwar, You have to write the "Marcus Parsons " explaination because what they asked in the question that exactly you have to present otherwise it gives you error. So please follow. Anwar, you have written very good and it is appreciated but last thing forgotten. Please correct it and enjoy JAVA coding.

Steve Kinsey
Steve Kinsey
4,463 Points

^^^yup, what they said^^^, PLUS notice that in your code you declared a String variable called firstName, but later in the code you try to reference it as firstname (i.e. without the camel case capital 'N'). I'm fairly new to Java myself, but already I've realised that making sure variable names always match exactly when you reference them is REALLY important. I'm getting into the habit of copying and pasting variable names directly from where I declare them when I need to reference them later in my code...it totally cuts out any typing errors or mismatches (btw you can't right click copy / paste in the practice exercises, but the Ctrl + C / Ctrl + V keyboard shortcuts work fine :-)

Hope that helps some...