(5<6 || 6<5) output true for what reason?

Why is the code bellow outputs true??? what are the || outputs in case of three expressions or more???



public class And {
	public static void main(String[] args) {

		System.out.println(5<6||6<5);
		
	}
}


OR short-circuits on true. Because the first operand is true, the expression returns true.

AND, on the other hand short-circuits on false, so the above would be false.

2 Likes

Thanks, now it sounds realy simple

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.