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

I tried to create a new variable equal to the user input, but I got an error I don't understand.

JavaTester.java:87: error: method readLine in class MockConsole cannot be applied to given types; String firstName = console.readLine(); ^ required: String,Object[] found: no arguments reason: actual and formal argument lists differ in length 1 error

Why doesn't it like the . between console and readLine?

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine();

When I put things in the parentheses I get this error:

JavaTester.java:88: error: cannot find symbol String lastName = console.readline("What is your last name"); ^ symbol: method readline(String) location: variable console of type MockConsole 1 error

3 Answers

Kaho Kang
Kaho Kang
12,383 Points

I have faced the same problem, now I passed. Try this: String name = console.readLine("");

Marileen Mennerich
Marileen Mennerich
1,161 Points

It seems that you forgot to capitalize the L in readLine in your second attempt. Your idea was correct, the readLine method asks for an input parameter. So, if you fix that littly typo, it should work out :)

Hi i think this can help.

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