%s
is a string in printf
, and %d is a decimal I thought...yet when putting in
writer.printf("%d dollars is the balance of %s\r\n", bal, nm);
..an exception is thrown telling me that %d
!= lang.double. Ideas?
%d
is for integers use %f
instead, it works for both float
and double
types:
double d = 1.2; float f = 1.2f; System.out.printf("%f %f",d,f); // prints 1.200000 1.200000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With