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

Add a variable to store a user’s first name using console.readLine. Make sure the variable is the camel cased representa

it keeps telling me to use camelCased and it is. what am i doing wrong

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
console.readLine("firstName  ");

2 Answers

As Dan says, you need to store a name in a variable named with camelCase convention.

So, you're storing a string, so it shoud be delcared as such and this string will hold the input of the console.readLine command.

Something like:

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

The value "Dave" will then be stored in firstName.

Dan Johnson
Dan Johnson
40,533 Points

If you were to call

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

This will present the user with the text "Dave" before their input. firstName will contain whatever was typed in after the prompt, and before a newline was encountered.

Oracle docs: http://docs.oracle.com/javase/7/docs/api/java/io/Console.html#readLine%28java.lang.String,%20java.lang.Object...%29

Sorry, I'm talking nonsense - Dan, thankfully, isn't!! :-)

Dan Johnson
Dan Johnson
40,533 Points

No worries, just didn't want any confusion over the String argument.

Dan Johnson
Dan Johnson
40,533 Points

The string passed into readLine is the prompt to the user. The return value from readLine is what contains the input and what you'll want to set a String variable (with the name of firstName as you had) to.