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 trialmartin li
1,026 Points%s I forget how the format of using these variable replacement operators do
Can somebody tell me how this works
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine("this is your first name");
String lastName = console.readLine("this is ur bchhh");
console.printf("First name: " + firstName);
1 Answer
Kevin VanderWulp
5,180 Pointsconsole.printf("First name: %s", firstName);
I believe this is the proper syntax for using %s. The printf command will see you added %s to the string, then search through the added arguments in order and replace %s with the argument.
martin li
1,026 Pointsmartin li
1,026 PointsThank you, I rewatched the video but yeah thank you for your answer! :)
martin li
1,026 Pointsmartin li
1,026 PointsThank you, I rewatched the video but yeah thank you for your answer! :)