三目运算符之判断奇偶

import java.util.Scanner;

public class ParityCheck {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Please input a number:");
        long number = sc.nextLong();
        String checkString= (number%2==0)?"偶数":"奇数";
        System.out.println(checkString);
    }
}
···

你可能感兴趣的:(三目运算符之判断奇偶)