Make a condition with restrictions Java Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Make a condition with restrictions Java without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Have a task on my education in Java: Make a condition, which is true if only one of X and Z values is less than 20. The way how to do that is like:

(X < 20 && Y >= 20) || (X >= 20 && Y < 20)

Or

(a < 20) != (b < 20)

But I have restrictions, it should be solved using no more than 2 comparison operators, no * / + – operators, no bitwise operators

Answer

 return Math.max(a, b) >= 20 && Math.min(a, b) < 20;
We are here to answer your question about Make a condition with restrictions Java - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji