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 trialStephen McBride
7,769 PointsCompiler error with declaring variable
There seems to be something wrong with this code when checking my work. I have ran it in workspace and it works no problem.
Could someone please explain to me where I have went wrong?
// I've imported java.io.Console for you. It is stored in a variable called console for you.
String name = console.readLine();
2 Answers
Aayush Mitra
24,904 PointsHi Stephen!
I assume that you are in task one, if you are not then please let me know.
I looked at your code and it was correct. I was confused too why it was not working. All you need to do is put in some text like so:
String name = console.readLine("What is your name?");
Hope this helped!
If this does not work or you are not on task one please let me know.
Thanks! :)
Stephen McBride
7,769 PointsYes that is the task I am on. I have just added in the text and it worked!
Thank you very much for your help. I did find it confusing as it didn't mention adding text.
Aayush Mitra
24,904 PointsYes I know, that was really weird. :)