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

Adam Bell
Adam Bell
1,176 Points

HELP ME

It says, "Add a variable to store a user’s first name using console.readLine. Make sure the variable is the camel cased representation of "first name"

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

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Adam;

Welcome to Treehouse!

If we break this task down into little bits, we have:

1) We need a camel case representation for a String variable named "first name," String firstName

2) We need to get input from a user via the console.readLine() function and pass it to our variable. Let's be nice and add in some prompting text.

String firstName = console.readLine("Please enter your first name: ");

That will print out Please enter your first name: to the console and accept a string value in as a response.

Please post back if you are still stuck.

Happy coding,

Ken

CamelCase are words written like that -> "camelCase" or "CamelCase". In Programming Languages it's more like "camelCase " for variables - the first letter is always a small one.

to add a value like your first name to a variable via the console.readLine method you have to actually first declare the variable:

"private String theVariable;"

after that you can define or specify it with a certain value. Actually you're putting a value into it by a user prompt with the console.readLine().

if you don't have a clue yet: "private String firstName = console.readLine("Please enter your first name: ");" is what you should write to solve the challenge.

Be sure to review the video once or twice before posting a question. I do this aswell because I might missed out a particular information aswell.

greets Charlie

Adam Bell
Adam Bell
1,176 Points

Thanks guys! Very informative answers.