当前位置:网站首页>分分钟掌握---三目运算符(三元运算符)
分分钟掌握---三目运算符(三元运算符)
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
边栏推荐
猜你喜欢
循环队列的基本操作(实验)
Pass in external parameters to the main function in clion
循环队列的基本操作,你学会了吗?
MySQL数据库讲解(十)
Operation instructions of star boundary text automatic translator
MYSQL一种分表实现方案及InnoDB、MyISAM、MRG_MYISAM等各种引擎应用场景介绍
After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
字节面试编程题:最小的K个数
redis数据库讲解二(redis高可用、持久化、性能管理)
x509证书cer格式转pem格式
随机推荐
setcontext getcontext makecontext swapcontext
MySQL数据库讲解(九)
Visio画拓扑图随记
MySQL lock database lock
KVM learning resources
OpenSSH的升级、版本号的修改
Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
顺序栈的基本操作
Golang 对分片 append 是否会共享数据
OpenStack命令操作
How does void * exist?
rsync+inotify远程同步
js 进度条,显示加载进度
redis数据库讲解二(redis高可用、持久化、性能管理)
js 格式化时间
一些小小小小记录~
mysql 5.1升级到5.66
DP - [noip2000] grid access
ssh限制登录的四种手段
LLVM - 生成局部变量