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

console.readLine(); is not working

I do not know how to answer " console.readLine " challenge 1/4 what would the answer be

String camelCase = console.readLine("What is your first name?" );

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

String camelCase = console.readLine("What is your first name?"  );

2 Answers

Liam Ferb
Liam Ferb
8,454 Points

Okay, I'm going to walk through what it's asking part-by-part, I'm not a big (or little) fan of just giving people the answer ('cause the journey is what's important), and while this is technically giving you the answer, you still get the journey, so its okay.

First of all it seems like you don't really know what camelCasing is, so camel-casing is joining the letters together, (thisisjoiningtheletters) then capitalise the start of each word, but don't capitalize the first one (thisIsCamelCasingOkay?).

To declare a String variable like it asks, you do this; String <Variable Name> <[optional but for this challenge mandatory] => <value>. Now it wants the camel cased version of first name, which is firstName, then to give it a value you place the =, (so far we have String firstName =). Now for the value it wants you to ask the consumer of your code, so in this case they are asking you to use console.readLine, now to ask the consumer a question you must have the question written, or they will have no idea what to write!!! so after console.readLine put parenthesis, (Console.readLine()) and then type your question (in double quotations), eg. "What is your (first) name? ", remember to leave two spaces after the question to help it look more natural.

So the answer is:

String firstName = console.readLine("what is your (first) name?  ");
Ronald Williams
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Ronald Williams
Java Web Development Techdegree Graduate 25,021 Points

The challenge says to make a variable called firstName and use console readLine to store the user input. That would be like this:

String firstName = console.readLine();