if statements to test the conditions, as follows:
if (x == 2) {
  if (y != 2) {
     System.out.println("Both conditions are true.");
   }
}
&&, || and !. 
&& is logical and. && combines two boolean values and returns a boolean which is true if and only if both of its operands are true. For instance
boolean b;
b = 3 > 2 && 5 < 7; // b is true
b = 2 > 3 && 5 < 7; // b is now false
|| is logical or. || combines two boolean variables or expressions and returns a result that is true if either or both of its operands are true. For instance
boolean b;
b = 3 > 2 || 5 < 7; // b is true
b = 2 > 3 || 5 < 7; // b is still true
b = 2 > 3 || 5 > 7; // now b is false
! which means not. It reverses the value of a boolean expression. Thus if b is true !b is false. If b is false !b is true. 
boolean b;
b = !(3 > 2); // b is false
b = !(2 > 3); // b is true
if (x == 2 && y != 2) {
  System.out.println("Both conditions are true.");
}