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


#1

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);
		
	}
}



#2

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.


#3

Thanks, now it sounds realy simple


#4

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