Java Java Basics Using your New Tools Multiple Format Strings

Stephen McBride
Stephen McBride
3,992 Points

Compiler 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?

Multiple.java
// 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
Aayush Mitra
17,332 Points

Hi 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
Stephen McBride
3,992 Points

Yes 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
Aayush Mitra
17,332 Points

Yes I know, that was really weird. :)