- 1、本文档共10页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java跳转语句(Java jump statement)
java跳转语句(Java jump statement)
2.3.5 jump statement
In addition to the if statements, switch statements, for statements, and while/do-while statements, Java also supports two other jump statements: the break statement and the continue statement. It is called a jump statement because Java makes the program move from the sequential execution to other parts through the two statements. Also note that there is no goto statement in Java, and the programs jump is implemented by means of break and continue.
1.break statement
In the switch statement, we have contacted the break statement, that is, it causes the program to jump out of the switch statement instead of sequentially executing the program in the following case.
In the loop statement, you use the break statement to jump out of the loop, ignoring any other statement of the loop body and the loop condition test. When a break statement is encountered in the loop, the loop terminates, and the program continues execution from the statement after the loop.
Unlike C and C++, there are no goto statements for arbitrary jumps in Java because the goto statement destroys the readability of the program and affects the compilation optimization. But Java can use break to implement some of the advantages of goto statements. Java defines an extended form of the break statement to handle this situation, that is, a tagged break statement. This form of break statement not only has the normal break statement jump function, but also can explicitly transfer program control to the designated place of the label. It should be emphasized that although this jump sometimes improves the efficiency of the program, it should be avoided. Tagged break statements are in the form of:
Break tags;
Look at the example below and take a closer look at the use of the break statement:
Int x = 0;
EnterLoop:// Tags
While (x 10) {
X++;
System.out.println (enter loop, initial value of X: + X);
Switch (x) {
Case 0:
System.out.println (enter switch statement, x=
您可能关注的文档
- 2012年幼儿园教师招聘考试试题-学前教育试题.(2012 kindergarten teacher recruitment examination questions - Preschool Education Questions).doc
- 2012年江西省中考语文试卷及答案(Chinese examination papers and answers in Jiangxi in 2012).doc
- 2012年淮安数学中考试卷(Huaian mathematics examination roll, 2012).doc
- 2012年滨州中考语文试题及答案(Chinese examination questions and answers in Binzhou 2012).doc
- 2012思想汇报(2012 thought report).doc
- 2012毕业感言(2012 graduation speech).doc
- 2012年6月6日申论辅导答案(June 6, 2012 Shanghai counseling answer).doc
- 2012情侣网名,qq情侣网名(2012 lovers screen name, QQ lovers screen name).doc
- 2012省部级真题申论答案(2012 provincial Statation Zhenti answer).doc
- 2012申论必威体育精装版专题(2012 on the latest topics).doc
文档评论(0)