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

Thomas Branch
Thomas Branch
1,178 Points

Java quiz parser broken

I am doing the last quiz on the first section of the java track. There is no way to satisfy the quizzes third task. I can't see an error in this code.

String firstName = ""; String lastName = ""; console.readLine("first name", firstName); console.readLine("last name", lastName); console.printf('first name: %s', firstName);

However, the interpreter gives me a "bummer". I've played around with formatting between double quotes and single quotes, the ordering of the lines, etc. All with the same result.

IO.java
// I have imported java.io.Console for you.  It is a variable called console.

String firstName = "";
String lastName = "";
console.readLine("first name", firstName);
console.readLine("last name", lastName);
console.printf('first name: %s', firstName);

3 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hey Daniel,

In Java single quotes and double quotes make a difference.

console.printf('first name: %s', firstName);

Single quotes are used to represent a char literal like this:

char letter = 'A';
String letters = "A";

They are different, we get into it in the next course, Java Objects. I should add a check assuming that error was a bit mind-blowing ;) Sorry for the frustration.

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

It shoud be

// I have imported java.io.Console for you.  It is a variable called console.

String firstName = console.readLine("Enter your first name: ");
String lastName = console.readLine("Enter your last name: ");
console.printf("First name: %s", firstName);
console.printf("Last name: %s", lastName);
Thomas Branch
Thomas Branch
1,178 Points

Hmmm, both should work. I passed tasks 1 & 2 with the readLines & string definitions as you see them.

Thanks for the fast response.