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
if (b = true) assigns the value true to b, and then acts on that true value. That's the danger of C-like languages, that if you leave out the second = when you meant to compare, you get an assignment instead, and an unexpected result.
if (b = true)
true
b
=