当前位置:网站首页>分分钟掌握---三目运算符(三元运算符)
分分钟掌握---三目运算符(三元运算符)
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
边栏推荐
- redis数据库讲解(四)主从复制、哨兵、Cluster群集
- 微信小程序轮播图swiper
- 逻辑卷创建与扩容
- Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)
- Quickly understand the three ways of thread implementation
- Gif to still image processing
- Notes on Visio drawing topology
- 差分隐私(背景介绍)
- Date的after时间判断
- SSH 通过跳板机连接远程主机
猜你喜欢
随机推荐
flannel 原理 之 TUN模式
使用Executors类快速创建线程池
Tongxin UOS uninstall php7 2.24, install php7 4.27 ; Uninstall and then install PHP 7.2.34
Redis源码分析之PSYNC同步
处理 mkdir:无法创建目录“aaa“:只读文件系统
ansible及常用模块的使用
线程间控制之CountDownLatch和CyclicBarrier使用介绍
Arrays类的使用案例
预览CSV文件
flannel 原理 之 子网划分
Mysql的安装过程(已经安装成功的步骤说明)
source insight via samba
ActiveMQ Basics
js 抛物线运动方法封装
void*是怎样的存在?
mysql 5.1升级到5.67
Operation instructions of star boundary automatic text translator (advanced version)
百度笔试2022.4.12+编程题目:简单整数问题
mysql查询库大小
循环队列的基本操作(实验)