Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java IO

Edward Asafu-Adjaye
PLUS
Edward Asafu-Adjaye
Courses Plus Student 1,415 Points

Java Basics - challenge parameter issues

Hey guys,

Can anyone help i keep getting this bummer error Error: Bummer! Did you forget to pass the lasttName parameter to the printf function?

My code is attached any helped would be most grateful.

Thanks

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("What is your name?  ");
console.printf("Hello my name is %s\n", firstName);
console.printf("%s is learning how to write java\n", firstName);
String lastName = console.readLine("What is your name?  ");
console.printf("Hello my name is %s\n", lastName);
console.printf("%s is learning how write java\n", lastName);
console.printf("First name:", firstName);
console.printf("Last name:", lastName);
Daniel Hildreth
Daniel Hildreth
16,170 Points

Hi there guys. I'm having this same issue and getting the parameter error. I have the following code. Can someone tell me what I'm doing wrong with my code so I can solve this challenge? I didn't want to just copy and paste others' answers. That is why I pasted my own code here.

// I have imported java.io.Console for you.  It is a variable called console.
String firstName = console.readLine("What is your first name?  ");
console.printf("Hello, my first name is %s\n", firstName);
console.printf("%s is learning Java\n", firstName);
String lastName = console.readLine("What is your last name?  ");
console.printf("My last name is %s\n", lastName);
console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);

4 Answers

Kumar Bharath H N
Kumar Bharath H N
8,324 Points

Hey Edward,

There is one small mistake in your printf statement, when you use printf you need to use something called format specifiers like %d for integers and %s for String so that the compiler will know where to place those arguments you write after the ,(comma). all you have to do is add %s

console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);
Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

To do parts 3 and 4 of this challenge, you still need to add the appropriate "%s" to fill in the first and last names.

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

You can do something similar with lastName to complete the challenge.

Iain Diamond
Iain Diamond
29,379 Points

Hi Edward,

console.printf("First name:", firstName);
console.printf("Last name:", lastName);

I believe the compiler warning is slightly misleading. The solution, if I recall correctly, is you need to add a %s to the last two printf lines to display the first and last names.

Hope this helps, iain

Edward Asafu-Adjaye
PLUS
Edward Asafu-Adjaye
Courses Plus Student 1,415 Points

WOW thank you all for such expedite responses. Really really helpful. Thank you very much :-) Iain Diamond kumar bharath hassan narasimha murthy Jon Kussmann

I can continue my journey.