当前位置:网站首页>Circular statements and arrays
Circular statements and arrays
2022-07-27 16:48:00 【.Null】
Loop statements and arrays
Summary of knowledge points : Loop statement And Array
Java There are three main cyclic structures :1) for loop 2) while loop 3) do…while loop Java enhance for loop
One . for( initialization ; Boolean expression ; to update ){ Code statements } example 1:
Two .while loop while It's the most basic cycle , Its structure is :
Format : while( Boolean expression ){ Cycle content } example 2:
3、 ... and 、do...while loop do…while Circulation and while Cyclic similarity , But the difference is ,do…while The loop will execute at least once
Format : do{ Code statements }while( Boolean expression ); example 3:
Four 、Java Enhanced for loop Java5 A kind of enhanced array is introduced for loop . But one thing to note :Java Enhanced for Cycle can only Value , Can't assign a value
Format : for( Statement statement : expression ){ Code sentence }
5、 ... and 、break、continue、return
1.)break : End of cycle 2.) continue : End this cycle , Enter next cycle
3.)return : End a way , The method is over , The cycle is naturally ended notice : stay while and do...while Use in continue Pay attention to the position of the updated statement .
5、 ... and . Declare array variables
notes : Array variables must be declared , To use arrays in a program . The following is the syntax format for declaring array variables :
example : Declare array variables byte[] arrayByteA; int[] arrayIntA; long[] arrayLongA; String[] arrayStringA;
1) Array initialization mainly includes Two ways : initiate static , dynamic initialization
* Array static initialization : arrayByteA=new byte[] {1,2,3,4,5};
Or array declared variables and initialization are completed in one statement byte[] arrayByteA=new byte[] {1,2,3,4,5,6};
* Array dynamic initialization arrbtC=new int[8];
Or array declared variables and initialization are completed in one statement int[] arrbtC=new int[2];
2) An array reference
Java Reference array elements by subscript in :arrayName[index];
Java The array elements will be checked for out of bounds to ensure security . Each array has one length Property to indicate its length ,
for example arrayIntA.length Indicates the array arrayIntA The length of .
边栏推荐
- 嵌入式面试
- Apache
- MQ Series 2: technology selection of Message Oriented Middleware
- Kubesphere multi node installation error
- Bean: the difference between model and entity
- CDQ divide and conquer and whole dichotomy learning notes
- Snowflake ID (go Implementation)
- C language output string in reverse order
- training on multiple GPUs pytorch
- Product axure9 English version, using repeater repeater to realize drop-down multi selection box
猜你喜欢
随机推荐
SolidWorks simulation curve attribute setting
Quadratic programming based on osqp
Opencv (II) -- basic image processing
(2) Dynamic convolution of dynamic convolution
training on multiple GPUs pytorch
[paper reading] transformer with transfer CNN for remote sensing imageobject detection
从零开始Blazor Server(1)--项目搭建
The image displayed online by TP5 is garbled
2021 national vocational college skills competition (secondary vocational group) network security competition questions (9) ideas
If you don't want to step on those holes in SaaS, you must first understand the "SaaS architecture"
CODIS cluster deployment
Configuration and application of gurobi in pycharm
Life game, universe 25 and striver
Is low code the future of development? On low code platform
Collection! 0 basic open source data visualization platform flyfish large screen development guide
Fast Planner - detailed explanation of kinetic astar
[paper reading] a CNN transformer hybrid approach for coding visual neuralactivity into text
【pytorch】|transforms.FiveCrop
自然排序:comparable接口,定制排序:compartor接口的区别
After the cubemx is reconfigured, the generated code cannot be opened successfully with IAR








