False boolean = True?

前端 未结 7 1027
粉色の甜心
粉色の甜心 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 02:56

     if(b = true)
    

    Well it is true because = is the assignment operator and not the equality operator ==

提交回复
热议问题