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 trial

Java Java Basics Getting Started with Java Strings, Variables, and Formatting

what 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...

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Ryan";
console.printf("%s can code in Java!");

3 Answers

Wut

Daniel Hartin
Daniel Hartin
18,106 Points

Hey 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

String myName = "Daniel";
int myAge = 30;

console.printf("my name is %s and I am %d years old",myName,myAge);

Hopefully this expands a little further and you can make sense of what was in the video.

Daniel

Daniel Hartin
Daniel Hartin
18,106 Points

Hi 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

I no speaka da chinese