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 Using your New Tools Multiple Format Strings

Melodie 1
Melodie 1
3,931 Points

I have a problem with the code challenge : Java basics - Multi format String

I don't quite understand why i won't pass ( i got stuck in the first step , where i need to create a variable called name and accept input using readLine() ) what i did is :

String name = console.readLine();

Multiple.java
// I've imported java.io.Console for you.  It is stored in a variable called console for you.
String name = console.readLine();

3 Answers

Todd Seabrook
Todd Seabrook
8,741 Points

A good way to check to see what is wrong is first to check out the 'Preview' Screen where you will see this error:

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

This means that they have a class called MockConsole that doesn't have the required arguments. The readLine method here is expecting an argument of String and an object array.

So in this case it doesn't look like they are using java.io.Console as stated, otherwise your code should have worked and would have complied on your system if you were working locally.

In this case it looks like they are expecting you to go off the example from the first video:

String name = console.readLine("Enter your name: ");

Hope this helps.

andren
andren
28,558 Points

+1 for a far more thorough answer than I bothered to write :smile:.

andren
andren
28,558 Points

While the task instructions doesn't specify it for this task you have to supply a input message to the readLine method. Something like this:

String name = console.readLine("What is your name?");
Melodie 1
Melodie 1
3,931 Points

Thanks a lot guys :)

Todd Seabrook
Todd Seabrook
8,741 Points

No problem, glad we could help :)