当前位置:网站首页>03|Process Control
03|Process Control
2022-08-10 01:47:00 【farming garden】
1 if statement
1.1 syntax
if(expression)
{
Execute action
}
1.2 Complex logic
Associative operator precedence writing condition:
- Highest priority: ()
- Lowest priority:=
- Priority: !>Arithmetic Operators>Relational Operators>&& >||
Note: Use parentheses for complex conditions to improve readability
1.3 Multiple if
- Syntax: if----else if --else
- if can only be in the first place, and there must be one
- else, only at the last and at most one
- else if in the middle, there can be several (0-n)
- if-else-if-else: It is judged from top to bottom, and the first result is true, execute the code, after the code block is executed, jump out
1.4 Nested if selection structure
- In order to make the code more readable, higher and more logical
- In a single code block, it is best not to exceed three levels of nesting at a time. If it exceeds, check the logic
2 swith statement
- The condition is not a boolean type, except for long unexpected integer + enumeration + string+char after jdk (1.7)
- The swtich comparison must be the equivalent judgment of the constant and the constant cannot be repeated
- break, prevent penetration
- switch is a separate scope
- switch does not need a comparison, finds the target at one time 6. defautl, when all conditions are not satisfied, execute default; it may or may not be
- can be in any position, but usually, we habitually put it at the first or at the end; if it is not at the end, we usually add break.
3 loops
3.1 while loop
3.1.1 Syntax
while(loop condition)
{
Execute action
}
3.1.2 The Four Steps of the Cycle
- Initial Conditions: Where to Start
- Judging conditions, where does it end
- The body of the loop is the main content of the loop execution
- Iteration: infinite approach to the goal
3.1.3 The difference between while and do-while loops
- When the condition is not met, do not execute it once; first judge that it is executing
- When the do-while loop, when the conditions are met, execute at least once; execute first, then judge
- Loops have fixed and variable lengths
- Order and Flashback
- Define step size
- Multiple criteria
3.2 for loop
3.2.1 Syntax
for(parameter initialization; conditional judgment; update loop variable)
{
Execute operation
}
For example: For( ; ; ){}
3.3 Jump and Skip
3.3.1 Syntax
Break //Jump out of all loops (only valid for the current loop)
Continue //Skip this loop (only valid for the current loop)
3.4 Flowchart
边栏推荐
- Redisson 分布式锁
- CST Studio Suite 2021 software installation package and installation tutorial
- Copper's emotion
- Next.js获取路由参数及styled-jsx 的使用
- How to activate the payment function on WeChat official account?
- Leetcode82. 删除排序链表中的重复元素 II
- 构建平衡二叉树「建议收藏」
- 线程的同步与互斥
- When knowledge and action are one
- 2022中高级Android面试题汇总来助你通过面试
猜你喜欢
为什么不建议你在 Docker 中跑 Mysql ?
线程的同步与互斥
温度响应性纳米水凝胶光子品体/纤维素修饰荧光水凝胶/载脂质体水凝胶的制备方法
字节技术面都过了,薪资都谈好了20K*13结果还是被刷了,问HR原因是。。。
The older tester has just passed the "hurdle" of being 35 years old, and I want to tell you something from my heart
技术分享 | 接口自动化测试如何处理 Header cookie
Leetcode81. 搜索旋转排序数组 II
Leetcode82. 删除排序链表中的重复元素 II
Web性能测试模型小结
3.9 - 正规表达式和正规集 3.10 - 有限自动机
随机推荐
错误提示:Syntax error on token “function”, delete this token
宝塔实测-搭建LightPicture开源图床系统
Docker interview question 2--get the number of database connections and docker-compose
技术分享 | 接口自动化测试如何处理 Header cookie
3.11-程序基本的控制语句 3.12-表达式 3.13-数据类型 3.14-常量/变量 3.15-标识符
Redis redisTemplate.execute 执行锁
ETCD快速入门-02 ETCD安装
2022中高级Android面试题汇总来助你通过面试
win10重装系统后没声音怎么办?
基于FPGA的任意字节数的串口接收(含源码工程)
阿雷的血压有些低
断开和服务器共享连接的方法「建议收藏」
Leetcode82. 删除排序链表中的重复元素 II
【obs】obsqsv11 硬编 及与metartc codec对比
openEuler 知:abi 检测
Project (7) - PolarSeg point cloud semantic segmentation
Koa中间件next实现
E - Sugoroku 3(期望dp)
Web性能测试模型小结
Tensor flow 踩坑记