The method's current form, below, has or (||) boolean operations meaning if any one pair matches, the method returns true.
private static boolean twoOutOfThreeSame(int i1, int i2, int i3, int k1, int k2, int k3) {
if (i1 == k1 || i2 == k2) {
return true;
}
if (i1 == k1 || i3 == k3) {
return true;
}
if (i2 == k2 || i3 == k3) {
return true;
}
return false;
}
Replacing the ors (||) with ands (&&) will have the behavior described by the method name. Alternatively the version below has the same behavior with one line.
private static boolean twoOutOfThreeSame(int i1, int i2, int i3, int k1, int k2, int k3) {
return (i1 == k1 && i2 == k2) || (i1 == k1 && i3 == k3) || (i2 == k2 && i3 == k3);
}
I think the logic in NATTypeDetection.twoOutOfThreeSame is likely backwards. The method name and code logic don't match.
The method's current form, below, has or (
||
) boolean operations meaning if any one pair matches, the method returns true.Replacing the ors (
||
) with ands (&&
) will have the behavior described by the method name. Alternatively the version below has the same behavior with one line.