public class Relational { public static void main( String args[] ) { int x1 = 5 ; int y1 = 5 ; Integer n1 = new Integer(47); Integer n2 = new Integer(47); //We know the below is false because //== compares addresses and not the contents System.out.println(n1 == n2); System.out.println(n1 != n2); //Must use equals System.out.println( n1.equals(n2) ); System.out.println( "x1 < y1 :" + (x1 < y1) ); System.out.println( "x1 <= y1 :" + (x1 <= y1) ); //True if x1 is not equal to y1 System.out.println( "x1 != y1 :" + (x1 != y1) ); y1 = 6 ; //&& Check if both conditions are true System.out.println( "((x1 < y1) && (y1 == 6 )) :" + ((x1 < y1) && (y1 == 6 )) ); //|| Check if one condition is true System.out.println( "((x1 < y1) || (y1 == 6 )) :" + ((x1 < y1) || (y1 == 6 )) ); //Short circuiting //If the first condition is false then the result will be //false so no need to evaluate (y1 == 6) System.out.println( "((x1 > y1) && (y1 == 6) ) :" + ((x1 > y1) && (y1 == 6 )) ); //If the first condition is true the second condition //is not evaluated. System.out.println( "((x1 < y1) || (y1 == 6 )) :" + ((x1 < y1) || (y1 == 6 )) ); } } //class