while( i <= j && i >= j && i != j) {}
how to declare i and j to make it be an infinite loop ?
// it\'s an interview q
Any equal value of 'i' and 'j' will reveal true with the given statement, say:
Integer i = new Integer(1);
Integer j = new Integer(1);
while( i <= j && i >= j && i != j) {}
The magic is with used operator! In case of != operator the compiler takes the operands as objects(including their values) whereas in case of >= or <= the compiler takes the operands value only. Thus, the above statement returns true.