public class TestMap {
public static void main(String[] args) {
System.out.println("请输入一个整数");
System.out.println();
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
if((number&1) == 1){
System.out.println("您输入的是奇数");
}else{
System.out.println("您输入的是偶数");
}
}
}
亲测可用.
if(你输入的数%2==0){
输出true;
}else{
输出false;
}
public class Test {
public static boolean judge(int num){
if(num%2==0){
return true;
}else{
return false;
}
}
public static void main(String[] args){
System.out.print(judge(2));
}
}