File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Printf and formatting problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Printf and formatting problem" Watch "Printf and formatting problem" New topic

Printf and formatting problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

In case of

Exception in thread "main" java.util.MissingFormatWidthException: -d

Exception in thread "main" java.util.MissingFormatWidthException: -,(d

the width is optional ,then why i am getting this exception

OCPJP 6.0 93%
OCPJWCD 5.0 98%
pete stein

Joined: Feb 23, 2007
Posts: 1561
mohitkumar gupta wrote:
the width is optional ,then why i am getting this exception

You are trying to left-justify the numeric output, and in this situation, a width value is required. For more details, please check out the API as this is all spelled out there:

I agree. Here's the link:
subject: Printf and formatting problem
It's not a secret anymore!