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

Output issue. Will not display printf and readLine functions. Error with creating Java Virtual Machine, fatal exception

When I hit preview, no output appears. Occasionally, when trying to preview or check my work, a window will pop up to inform me that there is a connection error and prompt me to restart the challenge. I assume these two issues might be related?

I have successfully completed tasks 1 and 2, but cannot get past task 3. Does this have anything to do with the fact that the output is not displaying correctly? Because the console isn't open, I can't give input for firstName and lastName values, but this shouldn't affect the validity of the code, should it?

Please let me know if there is an issue with my printf commands, or if I have somehow screwed up my string variables. If the problem is being caused by an output or communication issue, that would also be good to know. Thanks a lot!

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

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Can you try joining the two printf statements together?

you are doing (i.e. printing) things on two lines.. when you should in one line