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

Mohammed Aydid Hasan
Mohammed Aydid Hasan
444 Points

I have done the step 4 of Java basics exercise...but don't know why it is not accepting my task at the last bit.

what is the mistake of my last exercise?

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName ="Mohammed Aydid Hasan";
console.readLine("Mohammed Aydid Hasan", firstName);
String lastName = "Hasan";
console.readLine("Hey, my last name is %s\n", lastName);
console.printf("First Name:%s ", firstName);

1 Answer

Erick R
Erick R
5,293 Points

It is expecting the following format:

String firstName = console.readLine(); //Store first name in variable firstName
String lastName = console.readLine(); //Store last name in variable lastName
//Print out the first and last name
console.printf("First name:%s", firstName);
console.printf("Last name:%s", lastName);

Sometimes the compiler has various tests that are specific to a challenge, if the test fails it will result in an error in the challenge. Sometimes, the implementation can be correct but the test will still fail because of the test contents. I suggest just following the instructions to the line and avoid adding or coding to it. If you want to practice, use workspaces and compile there.