Java Java Basics Getting Started with Java IO

I'm not sure what's wrong here. I've tried it a few different ways, without the %s, with it, changed spacing...

I can't seem to find the problem. I've checked similar problems on the forums and used what they had for those solutions.

Thanks for the help.
// I have imported for you.  It is a variable called console.
String firstName = "Trevor";
String lastName = "Dotzler";

console.readLine("What is my first name?  ", firstName);
console.readLine("What is my last name?  ", lastName);

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

1 Answer

Steven Parker
Steven Parker
203,728 Points

To capture the input from a "readLine", the returned value must be assigned to the variable. The variable should not be an argument to the method. For example:

String firstName = console.readLine("What is my first name?  ");

It's also not necessary to assign the variable with something else first.