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 trialTyler Anyan
2,976 PointsTrouble with 3rd step of getting started with java challenge
I can't figure out what's wrong here and it seems so simple but no matter what I do (have tried a few different approaches) it errors and says I somehow broke task 2.
String firstName = "Tyler"; console.printf("Tyler can code in Java!"); console.printf(firstName, "can code in Java!");
// I have setup a java.io.Console object for you named console
String firstName = "Tyler";
console.printf("Tyler can code in Java!");
console.printf(firstName, "can code in Java!");
2 Answers
Tyler Anyan
2,976 PointsOk, took some messing around but I somehow missed some of the details regarding "%s" and what it does (calls in a variable that gets defined later to that point in the string). For anyone else having some headaches with that, it should look something like this:
// I have setup a java.io.Console object for you named console String firstName = "Tyler"; console.printf("%s can code in Java!", firstName);
Tyler Anyan
2,976 PointsOk well it looks like if the variable is coming first then using a comma doesn't work, checked with the google and it looks like it goes console.printf(firstName + "can code in Java!"); . Works in the workspace, hopefully challenge too.
Tyler Anyan
2,976 PointsScratch that. It works online, it works in workspace, not in the challenge. Back to the drawing board...