In java single | and & operators denote a bitwise or and bitwise and respectively.
The double || and && are used to denote logical or and logical and.
In our java code the single, bitwise operators are used in many places where a double, logical operator is semantically required.
Current counts across our java base indicate we have 1463 && operators and 1413 single & operators.
Additionally we have 840 || operators and 449 single | operators.
That leaves us with almost 2000 instances to investigate, correct, and test.
For now: low priority. If we encounter any such coding issues during maintenance, please correct those coding errors while the routine needs to be fixed and tested anyway.
&& if 1st condition is false, does not check 2nd condition
|| if 1st condition is true, does not check 2nd condition
First bullet means & and | do not "short-circuit". The StackOverflow example demonstrates how one
can get a null pointer exception with a statement like "if (str != null & str.equals("hello))".
In java single | and & operators denote a bitwise or and bitwise and respectively. The double || and && are used to denote logical or and logical and.
In our java code the single, bitwise operators are used in many places where a double, logical operator is semantically required. Current counts across our java base indicate we have 1463 && operators and 1413 single & operators. Additionally we have 840 || operators and 449 single | operators. That leaves us with almost 2000 instances to investigate, correct, and test.
For now: low priority. If we encounter any such coding issues during maintenance, please correct those coding errors while the routine needs to be fixed and tested anyway.
Example from https://stackoverflow.com/questions/1795808/and-and-or-in-if-statements