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


meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

0 1.200000 Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(
at java.util.Formatter$FormatSpecifier.printInteger(
at java.util.Formatter$FormatSpecifier.print(
at java.util.Formatter.format(
at StringExample.main(

My one regret in life is that I am not someone else.
- Woody Allen
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

As you can read here you should use "%d" for integers, and "%f" for both float and double values.

Edit: The 'd' in "%d" refers to number system (decimal), as stated in the API.

The quieter you are, the more you are able to hear.
Don't get me started about those stupid light bulbs.
subject: printf