当前位置:网站首页>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 .
边栏推荐
- PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
- A. Div. 7
- Keep an IT training diary 054- opening and closing
- Li Chuang EDA learning notes IX: layers
- Osnabrueck University | overview of specific architectures in the field of reinforcement learning
- Sword finger offer 14- I. cut rope
- Network byte order
- There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection
- [untitled] the relationship between the metauniverse and digital collections
- Record a problem that soft deletion fails due to warehouse level error
猜你喜欢
Lichuang EDA learning notes 14: PCB board canvas settings
[software implementation series] software implementation interview questions with SQL joint query diagram
High level application of SQL statements in MySQL database (I)
Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
Talking about custom conditions and handling errors in MySQL Foundation
From the 18th line to the first line, the new story of the network security industry
Take you to master the formatter of visual studio code
Node write API
String & memory function (detailed explanation)
Network communication basic kit -- IPv4 socket structure
随机推荐
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
Neo4j learning notes
[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
Example 072 calculation of salary it is known that the base salary of an employee of a company is 500 yuan. The amount of software sold by the employee and the Commission method are as follows: Sales
Design and implementation of redis 7.0 multi part AOF
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Problems and solutions of several concurrent scenarios of redis
求esp32C3板子連接mssql方法
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
WordPress collection WordPress hang up collection plug-in
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
中電資訊-信貸業務數字化轉型如何從星空到指尖?
Chain ide -- the infrastructure of the metauniverse
MySQL workbench use
Safety tips - seat belt suddenly fails to pull? High speed police remind you how to use safety belts in a standardized way
I stepped on a foundation pit today
Unity controls the selection of the previous and next characters
The difference between lambda expressions and anonymous inner classes
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
CSCI 2134