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

Why can't you have multiple console.printf's using the same strings?

I was doing a the final exercise in the first challenge task of Multiple Strings and I had to delete the previous console.printf's in order to get my final console.printf accepted. Apologies if I'm not utilizing the correct vocabulary -- open to learning that too!

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,468 Points

The issue is not about having multiple console.printf statements specifically. It a side-effect of the grader code that gets confused when searching the code output for the correct answer or it interprets the extra output as a "mistake". In the case of the Strings Variables And Formatting challenge, The console output for task 2 and 3 are the same, but when scanning the code to see if you used the %s formatting it can get confused by the other console.printf. I had to comment out the task 2 solution to get task 3 to pass.

The only reason I see this caused a problem is because the code challenges are very particular and only accept specific answers.