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

I honestly have no idea what I have done wrong. Can someone help?

Don't know maybe I am just tired and can't see what I have done wrong.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("What is your name?  ");
String lastName = console.readLine("What is your name?  ");
console.printf ("Hello, my name is %s/n" , firstName);

3 Answers

IO.java
// I have imported java.io.Console for you.  It is a variable called console.

// This will ask: 'Enter your first name: '
String firstName = console.readLine("Enter your first name:  ");

// This will ask: 'Enter your last name: '
String lastName = console.readLine("Enter your last name:  ");


// This will say: 'First name: <WHAT_YOU_ENTERED_IN_THE_FIRSTNAME_VARIABLE>'
console.printf("\nFirst name: %s\n", firstName);

// This will say: 'Last name: <WHAT_YOU_ENTERED_IN_THE_LASTNAME_VARIABLE>'
console.printf("Last name: %s", lastName);

// So together this will say:
// 'Enter your first name: 
// Enter your last name: 
// 
// 
// First name: 
// Last name: '

Make sense?

ISAIAH S

Yeah I understand it all thanks :)

Dan Johnson
Dan Johnson
40,533 Points

It just wants the format string to be "First name: %s" exactly.

Edit: Won't be used for this String, but the escape character is a backslash, so if you wanted a newline it would be "\n".

Oh woow (facepalm) It's amazing I even got this far if I can't do that. Thanks anyway.