Possible Duplicate:
Is it bad to explicitly compare against boolean constants e.g. if (b == false) in Java?
In this NotePadProvider sample code, I noticed that the author chose the form:
if (values.containsKey(NoteColumns.CREATED_DATE) == false) {
values.put(NoteColumns.CREATED_DATE, now);
}
Over:
if (!values.containsKey(NoteColumns.CREATED_DATE)) {
values.put(NoteColumns.CREATED_DATE, now);
}
Is there any advantage in the first form over the more logical one?
Apart from "readability", no. They're functionally equivalent.
("Readability" is in quotes because I hate == false
and find !
much more readable. But others don't.)