In Java, = is assignment and == is comparison. Mixing them up is one of the most frequent beginner bugs.
int x = 5;
if (x == 5) { // Correct: compares x to 5
System.out.println("Five");
}
If you accidentally write x = 5 inside the condition, Java catches it. Unlike C, Java requires the condition to be a boolean, so if (x = 5) produces a compile error because int is not boolean.
But with boolean variables, the compiler can't save you:
boolean done = false;
if (done = true) { // Bug: assigns true, then evaluates to true
System.out.println("Always runs");
}
This assigns true to done and then checks the result, which is always true. The fix is if (done == true) or just if (done). Build the habit of writing if (done) instead of if (done == true) to avoid this trap entirely.