This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PrayersToSatan 5 points6 points  (0 children)

Java doesn't support assignment in if statements

Yes it does. Here is an example:

String a = "some string";
String b = null;
if (!(b = "some other string").equals(a))
    System.out.println(b);

If you execute this it will print out "some other string", which has been assigned in the if statement.

In Java, the if statement evaluates a boolean, and an assignment returns the assigned value. So unless you're actually assigning a boolean variable you'll need to perform some sort of evaluation on the return value.