wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: http://java.sun.com/javase/6/docs/api/java/util/Formatter.html

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Printf and formatting problem
Similar Threads
producer/consumer problem
Illegal format conversion exception for printf
Error in System.out.printf format
How to wrap java programs in cmd.exe and bash?
Converting threadgroup to executorservice