当前位置:网站首页>分分钟掌握---三目运算符(三元运算符)
分分钟掌握---三目运算符(三元运算符)
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
边栏推荐
- Man man notes and @ reboot usage of crontab
- Introduction to loan market quotation interest rate (LPR) and loan benchmark interest rate
- 循环队列的基本操作,你学会了吗?
- Redis源码分析之HSET流程与ziplist
- IE8 browser prompts whether to block access to JS script
- 線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
- JS parabola motion packaging method
- dp-能量项链
- Nacos作为配置中心(四) 使用Demo
- std::map 和 std::vector 内存释放
猜你喜欢

OpenStack命令操作

处理 mkdir:无法创建目录“aaa“:只读文件系统

顺序栈的基本操作

MySQL数据库讲解(十)

Processing MKDIR: unable to create directory 'AAA': read only file system

顺序表的操作,你真的学会了吗?

Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface

Use the executors class to quickly create a thread pool

爬虫练习题(一)

Installation and use of postman pit
随机推荐
贷款市场报价利率(LPR)与贷款基准利率介绍
JS parabola motion packaging method
如何5分钟上手使用OCR
爬虫练习题(一)
After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
Qt界面优化:Qt去边框与窗体圆角化
LLVM - 生成for循环
Uni app message push
统信UOS PHP7.2.3升级至PHP7.2.24
js 进度条,显示加载进度
统信UOS卸载php7.2.24,安装php7.4.27 ;卸载再安装为PHP 7.2.34
redis数据库讲解(三)redis数据类型
gif转为静态图片处理
LLVM - 生成局部变量
JS progress bar, displaying the loading progress
Pass in external parameters to the main function in clion
快速搞懂线程实现的三种方式
Redis cluster 原理
線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口
文字组合,不重复,做搜索或查询关键字匹配