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 trialRyan Galle'
4,784 Pointswhat does: java.util.MissingFormatArgumentException: Format specifier '%s' () mean?
It's saying it, I have no clue what it means and I've watched that part of the videos twice...
// I have setup a java.io.Console object for you named console
String firstName = "Ryan";
console.printf("%s can code in Java!");
3 Answers
Ryan Galle'
4,784 PointsWut
Daniel Hartin
18,106 PointsHi Ryan
When you declare a string formatter i.e %s you must have an equal number of arguments passed into the method like the below
// I have setup a java.io.Console object for you named console
String firstName = "Ryan";
console.printf("%s can code in Java!",firstName);
This replaces the %s with the first argument passed in which in this case is the firstName variable.
Hope this helps Daniel
Ryan Galle'
4,784 PointsI no speaka da chinese
Daniel Hartin
18,106 PointsDaniel Hartin
18,106 PointsHey Ryan
Sorry but what don't you understand? simply putting 'wut' is neither proper English or helpful to anyone trying to expand on something which you don't understand.
The string formatters %s for a string or %d for an integer etc are intended to be used as a placeholder inside the string for you to slot in some other information, but how does the program know what to slot it? This is why you pass in as many arguments after the initial string into the method as you have placholders, that way the program can slot in these values like
Hopefully this expands a little further and you can make sense of what was in the video.
Daniel