当前位置:网站首页>分分钟掌握---三目运算符(三元运算符)
分分钟掌握---三目运算符(三元运算符)
2022-04-23 14:12:00 【Zinksl】
:::
根据 遗忘曲线:话说,种一颗树的最佳时间是十年前与现在
:::
三元运算符的格式:
判断条件 ? 值1 : 值2;
执行流程:
1 判断条件是否为真?
2 如果判断条件为真,则 值1 赋给这这条语句的结果;
3 如果判断条件为假,则 值2 赋给这这条语句的结果;
public void operator(){
int a,b,c;
a = 10;
b = 20;
//第一种情况判断条件(b>a)为真
c = b>a ? a:b;//c的值为10;
//第二种情况判断条件(b<a)为假
c = b<a ? a:b;//c的值为20;
}
版权声明
本文为[Zinksl]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Zinkse/article/details/123867059
边栏推荐
猜你喜欢

字节面试编程题:最小的K个数

Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)

进入新公司,运维工程师从下面这几项了解系统的部署

man man随记和crontab的@reboot用法

常见存储类型和FTP主被动模式解析

01-nio basic ByteBuffer and filechannel

OpenStack命令操作

KVM学习资源

Tongxin UOS uninstall php7 2.24, install php7 4.27 ; Uninstall and then install PHP 7.2.34

flannel 原理 之 TUN模式
随机推荐
Wechat applet rotation map swiper
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【1】
微信小程序轮播图swiper
Redis源码分析之HSET流程与ziplist
mysql 5.1升级到5.69
逻辑卷创建与扩容
ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory
man man随记和crontab的@reboot用法
Get the thread return value. Introduction to the use of future interface and futuretask class
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
微信小程序客服接入,实现发送和接收消息
Qt界面优化:Qt去边框与窗体圆角化
線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
Introduction to loan market quotation interest rate (LPR) and loan benchmark interest rate
Docker篇 (五) MySQL的安装
Notes on Visio drawing topology
uni-app消息推送
DP energy Necklace
正则表达式