Less than two variables

java

Solution

You can use the exclusive-OR operator:

(var1 > var2) ^ (var1 > var3)

`A ^ B` is `true` if and only if either `A` or `B` (but not both) are `true`:

A  B  A^B
---------
0  0   0
0  1   1
1  0   1
1  1   0

Problem

I have tried to search as much as I can but it's kinda hard when you are a beginner. Anyway im trying to learn Java and im stuck on a question that says "var1 can be bigger than var2 or var3 but not both. And im supposed to answer with a Boolean value. ``` e = var1 > var2 || var1 > var3 && var1 < var2 + var3; ``` If I do this I end up with it just doing a total sum of var2 and var3. How do I do like ``` var1 < var2 AND var3; ```

Original source