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 trialJim Garman
Python Web Development Techdegree Student 1,716 PointsError on Bottles of Milk - Java
I tried to enter this example into the workspace myself and I get the following error.
Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%d'
at java.util.Formatter.format(Formatter.java:2519)
at java.util.Formatter.format(Formatter.java:2455)
at java.io.Console.format(Console.java:170)
at java.io.Console.printf(Console.java:209)
at BottlesOfMilk.main(BottlesOfMilk.java:8)
My code is:
import java.io.Console;
public class BottlesOfMilk {
public static void main(String[] args) {
Console console = System.console();
for (int i = 99; i > 0; i--) {
console.printf("%d bottles of milk on the wall...%n");
}
}
}
1 Answer
Andrei Talpos
Courses Plus Student 6,739 PointsHi Jim, at the end of the printf statement you forgot to specify what %d was representing, which is the variable "i". Hope that helped!