at java.util.Formatter$FormatSpecifier.checkInteger(Unknown Source)
at java.util.Formatter$FormatSpecifier.<init>(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
while implementing this:
Isn't line 8 supposed to round off the value to two decimal places?
Khusbu Sinha wrote:
%f does the job here but what is %.2d supposed to do? What kind of values can it handle?
The precision field is not applicable with integral types. As for what is an integral type, they are (can be applied to) ... byte, Byte, short, Short, int and Integer, long, Long, and BigInteger (see JavaDoc link below).
Khusbu Sinha wrote:Can I get some links/resources to gain a thorough understanding?
The JavaDoc has a good chart / table that list everything...
It would have been a lot easier for you if I had got that format string right
Khusbu Sinha wrote:I am currently not comfortable with the syntax and functionality of printf. . . .
Try the version with my error corrected:- And I am very sorry for my mistake. Not d but f.
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Rocket Oven Kickstarter - from the trailbosshttps://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss