Is 1 represent true state in java or not and why ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is 1 represent true state in java or not and why ?

24th Feb 2017, 4:56 PM
Nilesh Tawar
Nilesh Tawar - avatar
2 Answers
+ 6
You can't assign 0 or 1 to a boolean value and you can't check e.g. if (boolean == 1); Results in a type exception.
24th Feb 2017, 6:31 PM
Tashi N
Tashi N - avatar
+ 3
@Tashi thanks, I learned what the boolean literal is in java. I delete my wrong answer to avoid it confuses people.
25th Feb 2017, 4:41 AM
seamiki
seamiki - avatar