| Author |
Sytstem.out.format
|
Mrinal Singhania
Greenhorn
Joined: Sep 30, 2012
Posts: 7
|
|
Hi,
The first line prints "true", while the second throws an exception. I don't understand why? AFAIK, booleans are not equivalent to ints/doubles, in that true != 1 and false != 0 in java.
Can someone please explain.
Thanks.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16686
|
|
Take a look at the javadoc for the java.util.Formatter class, particularly the chart about the behavior for each type.
'b', 'B'
general
If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(arg). Otherwise, the result is "true".
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Mrinal Singhania
Greenhorn
Joined: Sep 30, 2012
Posts: 7
|
|
Henry Wong wrote:Take a look at the javadoc for the java.util.Formatter class, particularly the chart about the behavior for each type.
'b', 'B'
general
If the argument arg is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(arg). Otherwise, the result is "true".
Henry
Hi Henry,
Thanks for the reply. And this solves my problem
Regards.
|
 |
 |
|
|
subject: Sytstem.out.format
|
|
|