Boolean literals are only two logical values that a boolean value can have, true
and false
.
The values of true
and false
cannot be converted to any numerical value.
The true
literal in Java does not equal 1, nor does the false
literal equal 0.
public class Main {
public static void main(String[] argv) {
boolean b = true;
int i = b;
}
}
If you try to compile the program, the following error message will be generated by compiler.
Main.java:5: incompatible types
found : boolean
required: int
int i = b;
^
1 error
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |