Ternary operator :

public static void main(String[] args) {
// TODO Auto-generated method stub
int time = 20;
String result = (time < 18) ? “Good day.”:”Good evening.”;
System.out.println(result);
}

out put – Good evening

task 2
public static void main(String[] args)
{
int no1 = 100, no2=200;
int bigger= (no1>no2)? no1 :no2;
System.out.println(bigger);
}
out put = 200

原文链接:Ternary operator :

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容