MissingFormatArgumentException

java.util.MissingFormatArgumentException: Format specifier '%s'

Quick Answer

Your format string has more placeholders than arguments. Add the missing arguments or remove extra format specifiers.

Why This Happens

String.format() and System.out.printf() throw this exception when the format string contains more %s, %d, or other specifiers than there are corresponding arguments. Each specifier must have a matching argument.

The Problem

String msg = String.format("Hello %s, you have %d messages from %s", "Alice", 5);
// Missing third argument for the third %s

The Fix

String msg = String.format("Hello %s, you have %d messages from %s", "Alice", 5, "Bob");

Step-by-Step Fix

  1. 1

    Identify the format string

    Find the String.format() or printf() call and count the format specifiers (%s, %d, %f, etc.).

  2. 2

    Count the arguments

    Count the arguments after the format string and compare with the number of specifiers.

  3. 3

    Add missing arguments or fix the format

    Provide the missing arguments, or remove extra format specifiers from the format string.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free