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
This is because the if-statement condition isn't a comparison. It's an assignment:
if(b = true)
Which will always return true. So it will always print true.
true
If you wanted to do a comparison, you need to use ==.
==