Java Java Basics Getting Started with Java IO

Sarah Hermansen
Sarah Hermansen
251 Points

Computer won't read console.readLine code. Am I doing this right?

"String firstName = console.readLine; " is the error here. The strange part is, the syntax error is the dot. Any help is appreciated.
// I have imported for you.  It is a variable called console.
String firstName = console.readLine;
console.printf ("Oh! Hey there! I was waiting to finally meet you! What's your name?  /n", firstName);
console.printf ("It's very lovely to meet you, %s .", firstName);

1 Answer

3,791 Points

Hello Sarah! You're missing the parentheses after the readLine method. Currently you have it like: "console.readLine;", it should be "console.readLine();". You have to type in the parentheses even if you're not writing anything inside it. Hope it helped :)