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

Curtis Wyman
Curtis Wyman
147 Points

String variable output

I don't understand how the value stored into string variable 'firstName' is not outputting the stored value after coding my 'printf' function.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
String firstName = "Curtis"; 
String lastName = "Wyman";


console.readLine(firstName); 
console.readLine(lastName);

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! To be honest, I'm not exactly sure why this passed the first two steps. What it's wanting is for what is being read in by the console.readLine to be assigned to the variables required. Here's a sort of pseudo-example of what it's looking for.

String streetAddress = console.readLine("Enter your street address:  ");

This will prompt the user to enter their address and then read in the user's input and assign it to the variable streetAddress. Right now, your code prints out a prompt with your name and then reads in something from the user, but it never assigns it anywhere.

I hope these hints help, but let me know if you're still stuck! :sparkles: