I am trying to write a method that compares three integers without using the if statement. I tried the switch statement, but it wouldn't work. Eclipse shows case expressions must be constants.
Here is a snippet of my code:
public boolean multipleValue(int n1, int n2, int n3)
{
boolean result = false;
switch (n1)
{
case num2:
case num3:
result = true;
break;
default:
result = false;
}
return result;
}
```
This line checks if a is equal to b and if b is equal to c. If both conditions are true, it returns true; otherwise, it returns false.
return (a == b)&&(b == c);