当前位置:网站首页>跳转语句的三种
跳转语句的三种
2022-04-22 06:21:00 【爱喝咖啡的佑佑】
break:在任何循环语句中的主体部分,均可用break控制循环流程,break用于强行退出循环,并执行循环中剩下的语句。
改变程序控制流。用于do-while,while,for可跳出循环而执行后面的语句(对录入的分数进行判 断,如果小于0,就会标记为出错的状态,并会立即跳出整个for循环)
continue:语句用在循环语句中,用于终止某次循环过程,即跳过循环体中尚未执行的语句,接着进行下一次是否执行循环的判定。
return:从当前方法退出,返回到调用调用该方法的语句处,并从该语句的下条语句处继续执行。
返回语句的两种格式:
1.return expression:返回一个值给调用该方法的语句(返回值的数据类型必须和方法声明中 的返回值类型一致或是精度低于声明的数据类型)
2.return:当方法声明中用void声明返回类型为空时,应使用这种返回类型,它并返回任何值。
所以总结一下就是:
break:switch 语句,循环语句
countinue:循环语句
return:任何语句结束当前方法和循环其实是没有什么关系的
版权声明
本文为[爱喝咖啡的佑佑]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_64131008/article/details/122068947
边栏推荐
- 信息系统项目管理师---第四章项目整体管理历年考试题
- Bidirectional circular linked list (see details)
- ES6模块化与Promise
- SUCTF 2019 EasySQL
- Ffmpeg Command (vi), video extraction audio video
- 常用的异常
- Installation and configuration of Yapi (Reprint)
- Leetcode - 1 - (substructure, combination, spiral matrix and full arrangement of tree < Ⅰ Ⅲ >)
- 使用使用使用
- VAD virtual memory
猜你喜欢

The best way to learn

Leetcode - 6 - (string multiplication, next larger element < Ⅰ Ⅱ Ⅲ >, K sets of inverted linked list)

2019.1.2版的Idea使用教程

Page properties

Redis的设计与实现(4):什么是Redis的事件驱动程序

并发编程的艺术(11):JUC里的工具类介绍

Redis的设计与实现(6):Redis如何实现高可用

信息系统项目管理师---第四章项目整体管理历年考试题

L1-071 previous life files (20 points) (similar two points)

E. Figure skiing (string sorting / check-in) (Game 5 of 2021 training League warm-up training competition)
随机推荐
set方法和get方法
Codeforces Round #588 (Div. 2) C D
The system log file is too large
Driver communication with R3 - custom package
[method overload]
APC (IV)
Addition, deletion and search of sequence table (find)
Failed to update PIP all the time? Most of them are network problems!
Change DP (ah ah ah)
IDEA的下载和配置
Abstract classes and abstract methods
UNICODE_ STRING
Deep understanding of MySQL (7): how to tune MySQL
Minimum circle coverage (basis of computational geometry)
Use of ansible
Ansible的使用
Queue (detailed explanation) -- hand tearing queue exercises
Explanation and use of interface
B. Ball dropping (simple geometric calculation / similar triangle) (2021 Niuke summer multi school training camp 1)
[calling method]