一:模2求余
public void judgeParity(int num){
if (num%2==0)
System.out.println("偶数");
else
System.out.println("奇数");
}
二:移位运算
public void judgeParity(int num){
if ((num & 1)==0)
System.out.println("偶数");
else
System.out.println("奇数");
}