java流程控制基础知识(小宗学编程九Java中的流程控制)

java流程控制基础知识(小宗学编程九Java中的流程控制)(1)

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语句三种格式

java流程控制基础知识(小宗学编程九Java中的流程控制)(2)

第一种

if(条件表达式){

执行代码块;

}

if-else loop in branch structure

three structures

The first

Three forms of if statement

if(conditional expression){

execute code block;

}

第二种

java流程控制基础知识(小宗学编程九Java中的流程控制)(3)

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新学苑原创,欢迎关注,带你一起长知识。

排版:谢宗佑

文字:谢宗佑

审核:李小雪

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页