三元运算符
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
package test; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.PrintStream; import java.util.Scanner; import com.sun.org.apache.bcel.internal.generic.NEW; /** * @author 年浩 * */ public class test { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scann = new Scanner(System.in); System.out.println("请输入一个数:"); long num = scann.nextLong(); String check = (num%2==0)?"偶数":"奇数"; System.out.println("输入的是一个"+check); } }
三运运算符,不多说。