当前位置:网站首页>goto语句
goto语句
2022-07-30 05:51:00 【Code Writers】
C语言中goto语句只能在同一个函数段中使用
用法如下:
goto:标签; // 到标签位置
标签:
下图中goto语句的作用相当于break语句。
Java继续使用标签机制,但又不同于C的goto语句用法:
Java的goto语句仅能用于循环语句中
搭配break使用
带标签的break会中断并跳出标签所指的循环。搭配continue使用
带标签的continue会到达标签的位置,并重新进入紧接着标签后的循环中。
goto语句的滥用容易导致代码逻辑结构混乱且增加代码阅读的难度,所以一般来说goto语句在C语言中用的较少,在Java语言中用的更少。
边栏推荐
- Selenium01
- MYSQL-GROUP BY 用法 全网最精,通熟易懂的话解释
- The terminal connection tools, rolling Xshell
- Huawei released "ten inventions", including computing, intelligent driving and other new fields
- node.js中实现对数据库的链式操作
- 不会吧,Log4j 漏洞还没有完全修复?
- Process and Scheduled Task Management
- 矩阵的行列式的计算及其源码
- @Bean 与 @Component 用在同一个类上,会怎样?
- schur completement
猜你喜欢
随机推荐
Go 使用mencached缓存
mysql高阶语句(一)
Mobile phone side scroll to page to specify location
“AI教练”请进家,家庭智能健身蓬勃发展
千万级数据量的表,怎样最快速度查询?
学生成绩管理系统(C语言)
Let the "label" content in Baidu map generator expand--solution
STL源码剖析:迭代器的概念理解,以及代码测试。
矩阵的行列式的计算及其源码
计算矩阵的逆源码(使用伴随矩阵,3×3的矩阵)
引导过程与服务控制
阿里二面:列出 Api 接口优化的几个技巧
The terminal connection tools, rolling Xshell
How to use Swagger, say goodbye to postman
进程和计划任务管理
限塑令下的新材料——聚乳酸(PLA)
STL源码剖析:bound friend template friend代码测试和理解
DHCP principle and configuration
DHCP原理与配置
Rodrigues: vector representation of rotation matrices