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 Strings, Variables, and Formatting

Dipanjan Dey
Dipanjan Dey
9,374 Points

Error in Task 3/3 of "Strings, Variable & Formatting" exercise

my code looks correct to me and compiles rightly in preview. But I keep on getting the following error message:

"Bummer! Please make sure you leave your printf statement intact"

Can someone please let me know what mistake I'm making? Am I understanding the task wrong?

my code (also attached):

String firstName = "DD"; console.printf ("%s can code in Java", firstName);

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "DD";
console.printf ("%s can code in Java!", firstName);

6 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Weird! Try it without the space between printf and the opening parenthesis.

Angle brackets are not required in the text, just your name.

Let me know if that works! Sorry for the frustration!

They want it to display as: <DD> can code in Java!, i.e., with the < and > symbols:

String firstName = "DD";
console.printf ("<%s> can code in Java!", firstName);
Dipanjan Dey
Dipanjan Dey
9,374 Points

Thanks for replying. But this doesn't appear to solve the problem. I used your code as it is - but still getting the same error

Just tried it again, with no problem, so this is getting a bit interesting!! When I first opened the page just now, the angle brackets around %s were missing, and I had to refresh the page to see them. It has to be <%s> or it won't work, as that's the only difference between yours and mine.

Dipanjan Dey
Dipanjan Dey
9,374 Points

very strange. When I use the same code with <%s>, I still am getting the same error!

just to reconfirm - this is the only bit of code you used, right?

String firstName = "DD"; console.printf ("<%s> can code in Java!");

Yes. I just did it again and it worked fine. I copied the two lines of code above, switched to the challenge, pasted them in and clicked Check Work.

Dipanjan Dey
Dipanjan Dey
9,374 Points

for some strange reason the exact smae thing isn't working for me. Still getting the error message in the 3rd task

I've reached out to treehouse helpdesk as well. hopefully they will chime in...

As they say: That's a real bummer. Good luck with the helpdesk.

Dipanjan Dey
Dipanjan Dey
9,374 Points

Thanks a ton for your response Craig!

turns out that space between printf & opening parenthesis was causing the problems. weird, but at last I'm able to finish the challenge

thanks again