📜  在java代码示例中使用按位运算符检查奇偶不

📅  最后修改于: 2022-03-11 14:52:36.403000             🧑  作者: Mango

代码示例1
// Using bitwise AND
if((n&1)==0)
  System.out.println("n is even");
else
  System.out.println("n is odd");

// Using bitwise OR
if((n|1)>n)
  System.out.println("n is even");
else
  System.out.println("n is odd");