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 trialHianoo Song
6,812 Pointsprintf
I'm having trouble with this question. I don't know why console.printf("<%s>",firstName); is incorrect for "check work". web workspace prints <firstName>.
// I have setup a java.io.Console object for you named console
String firstName = "Hyunwoo";
console.printf("<%s>",firstName);
Hianoo Song
6,812 PointsTurns out there is no need for 'greater than' and 'less than' signs. My bad.
1 Answer
Steve Hunter
57,712 PointsHi there,
You can simplify that still further as there's no need to interpolate into an empty string:
String firstName = "Hyunwoo";
console.printf(firstName); // no interpolation
console.printf("%s can code in Java!", firstName); // interpolation needed
So, you can print a string directly inside the printf
method, but if you want to use a string's value inside another string, you use the formatter with the %s
(for a string - numbers etc are slightly different).
I hope that helps,
Steve.
Hianoo Song
6,812 PointsI misunderstood the question. Thanks anyway~
Steve Hunter
57,712 PointsAs long as you got it sorted, that's great.
Steve.
Jimmy Nguyen
1,940 PointsJimmy Nguyen
1,940 Pointsare the the signs "great than" "less than" needed?