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

Jan Lundeen
Jan Lundeen
5,554 Points

Getting java.util.MissingFormatArgumentException: Format specifier '%s' () error-Challenge 3 of 3-strings variables-Java

I'm getting a java.util.MissingFormatArgumentException: Format specifier '%s' () error-Challenge 3 of 3 for strings and variables in Java Basics. Challenge 3 of 3 - Now replace <YOUR NAME> in the console.printf expression with the firstName variable using the string formatter:

Here's my code:

String firstName = "Jan";
console.printf ("%s can code Java!");

Here's the error I received:

Bummer: java.util.MissingFormatArgumentException: Format specifier '%s' ()

Is "using the string formatter" referring to %s? I'm not sure what I did wrong.

Thanks,

Jan

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

2 Answers

Juan Jaramillo
Juan Jaramillo
5,480 Points

Since you used %s you have to specify which string is going to replace that %s once the console prints. It should be among the lines of :

console.printf ("%s can code Java!" , firstName);

Jan Lundeen
Jan Lundeen
5,554 Points

Thanks Juan! That worked.