public class XorOp { public static void main(String[] args) { int x = 18; if ( (x%2 == 0) ^ (x%3 == 0) ) { System.out.println("number is divisible by 2 or 3"); System.out.println("but not by BOTH"); } } }