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

It keeps asking if I forgot to pas the firstName function throught my parameter. I'm not sure what I'm doing wrong

I'm on step 3.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = ("Bryce");
  console.readLine("%s, firstName");
String lastName = ("Hunter");
  console.readLine("%s, lastName");
console.printf("First name: %s",firstName);

2 Answers

Ryan Ruscett
Ryan Ruscett
23,309 Points

Hey,

Took me a minute to get to this question.

Let's walk down your code. You totally had the right idea, in the way that the question reads. It would make sense to do what you did.

QUESTION: Declare a variable that is named the camel-cased version of "first name". Store the user's first name into this new variable using console.readLine.

I can see where you go this from.

String firstName = ("Bryce");
console.readLine("%s, firstName");

What this should really look like is this.

String firstName = console.readLine("Ryan");

This ensures that what is being read in is set to FirstName. What you did was a bit different. Let's talk about that for a second.

You are saving a variable to your name. You don't actually need the parenthesis.

String firstName = "Bryce";

Although that does create a variable so I am ok with that at this time. The second thing you do is console.readLine variable first name. Yeah so that kinda works and passes the challenge. But it's not what the test behind the scenes is looking for. It's looking Yes, the output for task 1 and 2 will pass since it just checks the output. Which technically you are still ok.

When it comes to the task 3 it is looking for specifics. It is looking for this.

String firstName = console.readLine("Ryan");
String lastName = console.readLine("Says hi");

console.printf("First name: %s", firstName);

It's looking for you to read the line in via the console and save it to firstName. Then use that in the console.printf.

I mean technically console.printf should of printed the variable. Except the test on treehouse checks to make sure you are doing it in a certain way. That's all I can assume.

Anyway, let me know if this helps you out and if you have any other questions I can help you with.

Christiaan Quyn
Christiaan Quyn
14,706 Points

Thanks Ryan, this was exactly the answer to the problem I was having as well :)