- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
JAVA精品课程PPT-savitchAbsJavaPPT_c03
Chapter 3 Flow of Control Flow of Control As in most programming languages, flow of control in Java refers to its branching and looping mechanisms Java has several branching mechanisms: if-else, if, and switch statements Java has three types of loop statements: the while, do-while, and for statements Most branching and looping statements are controlled by Boolean expressions A Boolean expression evaluates to either true or false The primitive type boolean may only take the values true or false Branching with an if-else Statement An if-else statement chooses between two alternative statements based on the value of a Boolean expression if (Boolean_Expression) Yes_Statement else No_Statement The Boolean_Expression must be enclosed in parentheses If the Boolean_Expression is true, then the Yes_Statement is executed If the Boolean_Expression is false, then the No_Statement is executed Compound Statements Each Yes_Statement and No_Statement branch of an if-else can be a made up of a single statement or many statements Compound Statement: A branch statement that is made up of a list of statements A compound statement must always be enclosed in a pair of braces ({ }) A compound statement can be used anywhere that a single statement can be used Compound Statements if (myScore your Score) { System.out.println(I win!); wager = wager + 100; } else { System.out.println (I wish these were golf scores.); wager = 0; } Omitting the else Part The else part may be omitted to obtain what is often called an if statement if (Boolean_Expression) Action_Statement If the Boolean_Expression is true, then the Action_Statement is executed The Action_Statement can be a single or compound statement Otherwise, nothing happens, and the program goes on to the next statement if (weight ideal) calorieIntake = calorieIntake – 500; Nested Statements if-else statements and if statements both contain smaller statements within them For example, single or compound
您可能关注的文档
最近下载
- 中招英语质量分析.pptx VIP
- 北师大版六年级上册数学知识点汇总(精华版).docx
- 课程思政在小学英语教学中的实施效果教学研究课题报告.docx
- 《语言障碍的康复》课件.ppt VIP
- 2025年中国小家电未来发展趋势分析及投资规划建议研究报告.docx VIP
- 语言与言语训练的方法课件.ppt VIP
- 统编版2024道德与法治七年级上册 教材单元思考与行动解答示例.pptx
- DB52T 780—2012贵州省白酒工业旅游示范点评定规范.pdf VIP
- 2025年医院招聘考试公共基础知识历年试题及答案解析(4).docx VIP
- (2025秋新版)北师大版三年级数学上册《铅笔有多长》PPT课件.pptx VIP
文档评论(0)