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 trialNathaniel Boonzaaijer
Full Stack JavaScript Techdegree Student 8,607 PointsIO.java printf not working?
I watched the video 2 times and I have no idea what I did differently, please assist.
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine();
String lastName = console.readLine();
console.printf("First name: %s\n");
1 Answer
Yusuf Mohamed
2,631 PointsFirst of all these challenges tends to be quite picky so don't add unnecessary stuff like the lastname string, it was never requested by you.
Secondly the error you is doing is that when you use %s you have to afterwards add which variable you're using because otherwise the compiler won't know what to add instead of %s. The correct code is
// I have imported java.io.Console for you. It is a variable called console.
String firstName = console.readLine();
console.printf("First name: %s\n",
firstName);
Please write back if you understood or not and if you have more questions just shoot.
Nathaniel Boonzaaijer
Full Stack JavaScript Techdegree Student 8,607 PointsNathaniel Boonzaaijer
Full Stack JavaScript Techdegree Student 8,607 Pointsthx, i dont know how i missed that, lol
Yusuf Mohamed
2,631 PointsYusuf Mohamed
2,631 PointsNo Problemos.