Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java IO

Michael Cohen
Michael Cohen
355 Points

What is a format string and where do I write this "First Name" that's being asked for? What name do I use?

This is very cryptic and difficult to understand. For instance, Why do certain letters in the middle of words need capitalization?

Is there a glossary of terms and what they mean? This might be helpful as a reference...

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 Mike", firstName);
console.printf("Mike is learning how to write Java/n", firstName);

1 Answer

Hi Michael,

Camel casing is just having the first word be lowercase and any following words have a capital starting letter. So, if I said to create a variable using the words your first name and camel case it, you would put "yourFirstName". The challenges tell you what they want you to do, but not how to do it; after all, the job of a programmer is to figure out the how ;)

With that being said, in the 3rd task the challenge tells you to print the string "First name: " and then the user's first name. The user's first name is stored in the variable firstName. You need to put a formatted string into the printf command. Use the %s placeholder to insert the variable into the string. Anywhere the Java compiler sees a %s in the string, it is going to replace it with the variable(s) you specify.

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

And it's the same concept with dealing with the last name.

Michael Cohen
Michael Cohen
355 Points

Hi Marcus,

I'm still kinda confused. Where do you put the actual name, like "Mike", as opposed to where you write" firstName"? It seems like the name disappears from the code at some point. Where do we initially specify the name that then get represented by "%s"?

I was referencing where you went wrong in your code with that snippet of code I posted. You are right with your creation of the firstName and lastName variables. That little snippet of code belongs in the same place as your first printf command.