False boolean = True?

前端 未结 7 1044
粉色の甜心
粉色の甜心 2020-12-07 02:12

I found this code in a book and I executed it in Netbeans:

boolean b = false;
if(b = true) {
    System.out.println(\"true\");
} else {
    System.out.printl         


        
7条回答
  •  醉话见心
    2020-12-07 03:04

    Think of int x having 2 possible values, either 1 or 0. If x = 1, then do this. Else, (x = 0) then do something else. Boolean is just saying it is either one condition, or not that condition.

提交回复
热议问题