前言:
现在大家对“流程控制java”可能比较关切,你们都需要分析一些“流程控制java”的相关知识。那么小编在网摘上网罗了一些关于“流程控制java””的相关内容,希望姐妹们能喜欢,你们快快来了解一下吧!Java中的流程控制
分享兴趣,传播快乐,增长见闻,留下美好!亲爱的您,这里是LearningYard新学苑。今天小编为大家带来“Java中的流程控制”,欢迎您的访问。
Share interests, spread happiness, increase knowledge, and leave good news! Dear you, this is the new LearningYard Academy. Today, Xiaobian brings you "Flow Control in Java", welcome your visit.
Java学习入门——流程控制
流程控制
流程控制语句是用来控制程序中各语句执行顺序的语句,可以把语句组合成能完成一定功能的小逻辑模块。
其流程控制方式采用结构化程序设计中规定的三种基本流程结构,即:
➢顺序结构
程序从上到下逐行执行,中间没有任何的判断和跳转。
➢分支结构
①根据条件,选择性的执行某段代码
②有if-else和Switch-case两种分支语句
➢循环结构
①根据循环条件重复性的执行某段代码
②有while、do-while、for三种循环语句
③JDK1.5提供了foreach循环,方便的游历集合,数组元素。
A flow control statement is a statement used to control the execution order of each statement in a program. The statement can be combined into a small logic module that can complete a certain function.
Its process control method adopts three basic process structures specified in structured programming, namely:
➢Sequence structure
The program is executed line by line from top to bottom, without any judgment or jump in the middle.
➢Branch structure
① According to the conditions, selectively execute a certain piece of code
②There are two branch statements: if-else and Switch-case
➢Circular structure
① Repeatedly execute a certain piece of code according to the loop condition
②There are three kinds of loop statements: while, do-while, and for
③JDK1.5 provides a foreach loop, which is convenient to travel through collections and array elements.
分支结构中的------if-else循环
三种结构
if语句三种格式
第一种
if(条件表达式){
执行代码块;
}
if-else loop in branch structure
three structures
The first
Three forms of if statement
if(conditional expression){
execute code block;
}
第二种
if(条件表达式){
执行代码块1;
}
else {
执行代码块2;
}
the second
if(conditional expression) {
execute code block 1;
}
else {
execute code block 2;
}
第三种:多选一
if(条件表达式){
执行表达式1;
}else if(条件表达式){
执行表达式2;
}else if(条件表达式){
执行表达式3;
}
...
else{
执行表达式n;
}
The third type: multiple choice
if(conditional expression) {
execute expression 1;
}else if(conditional expression){
execute expression 2;
}else if(conditional expression){
execute expression 3;
}
...
else{
execute expression n;
}
今天的分享就到这里了。如果您对今天的文章有独特的想法,欢迎给我们留言,让我们相约明天,祝您今天过得开心快乐!That's it for today's sharing. If you have a unique idea about today’s article, Welcome to leave us a message. Let us meet tomorrow, I wish you a happy day today!
END
翻译:来自Googl翻译
本文由LearningYard新学苑原创,欢迎关注,带你一起长知识。
排版:谢宗佑
文字:谢宗佑
审核:李小雪
标签: #流程控制java