当前位置:网站首页>Enhanced for loop
Enhanced for loop
2022-07-04 02:36:00 【XGTX1998】
1、 Introduce
enhance for The role of circulation : Simplify the writing format of iterators .( Be careful : enhance for The bottom layer of the loop still uses iterator traversal .)
enhance for Scope of application of the cycle : If it is realized Iterable Interface objects or array objects can be enhanced for loop .
enhance for Disadvantages of circulation : enhance for Circulation and iterator The effect of traversal is the same , That is to say, enhance for The inside of the loop is the call iteratoer Realized , But enhance for Circulation has some disadvantages , For example, you can't dynamically delete the contents of a collection in an enhancement loop 、 Can't get subscripts, etc .
2、 enhance for The format of the loop
for( data type Variable name : Traversal target )
{
data type
Variable name : Declare a variable to receive the element after traversal of the traversal target
}
3、 enhance for Circulation considerations
1、 enhance for The bottom layer of the loop is also obtained by using iterators , Just get the iterator by jvm complete , We don't need to get iterators , So we're using enhancements for In the process of looping variable elements, it is not allowed to use set objects to modify the number of elements in the set .
2、 Iterators traverse elements and enhance for The difference between cyclic variable elements : When iterators are used to traverse the elements of a collection, the elements of the collection can be deleted , And enhance for When looping elements of a variable set , Cannot call iterator's remove Method deletion except Elements .
3、 Ordinary for Circulation and enhancement for Difference between cycles : Ordinary for A loop can have no traversal target , And enhance for Loops must have traversal targets .
边栏推荐
- Keep an IT training diary 055- moral bitch
- Optimization theory: definition of convex function + generalized convex function
- MySQL advanced (Advanced) SQL statement (I)
- Question d: Haffman coding
- Career development direction
- LV1 Roche limit
- Portapack application development tutorial (XVII) nRF24L01 launch C
- Will the memory of ParticleSystem be affected by maxparticles
- Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
- Network byte order
猜你喜欢
What are the conditions for the opening of Tiktok live broadcast preview?
Bacteriostatic circle scanning correction template
Talking about custom conditions and handling errors in MySQL Foundation
WordPress collection WordPress hang up collection plug-in
17. File i/o buffer
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Problems and solutions of several concurrent scenarios of redis
Backpropagation formula derivation [Li Hongyi deep learning version]
C learning notes: C foundation - Language & characteristics interpretation
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
随机推荐
Talking about custom conditions and handling errors in MySQL Foundation
Buuctf QR code
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
The difference between lambda expressions and anonymous inner classes
The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"
Override and virtual of classes in C #
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
C # learning notes: structure of CS documents
The difference between int (1) and int (10)
Mysql-15 aggregate function
Format character%* s
Servlet simple verification code generation
Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
Chain ide -- the infrastructure of the metauniverse
PMP daily three questions (February 14, 2022)
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
基於.NetCore開發博客項目 StarBlog - (14) 實現主題切換功能
Site favorites
Neo4j learning notes
Résumé: entropie, énergie libre, symétrie et dynamique dans le cerveau