当前位置:网站首页>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 .
边栏推荐
- Bacteriostatic circle scanning correction template
- 13. Time conversion function
- Global and Chinese market of cell scrapers 2022-2028: Research Report on technology, participants, trends, market size and share
- Network communication basic kit -- IPv4 socket structure
- Save Private Ryan - map building + voltage dp+deque+ shortest circuit
- Gee import SHP data - crop image
- Basic editing specifications and variables of shell script
- 3D game modeling is in full swing. Are you still confused about the future?
- The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
- [untitled] the relationship between the metauniverse and digital collections
猜你喜欢
[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)
String & memory function (detailed explanation)
Problems and solutions of several concurrent scenarios of redis
Li Chuang EDA learning notes IX: layers
AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
LV1 previous life archives
Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
JVM performance tuning and practical basic theory - medium
[software implementation series] software implementation interview questions with SQL joint query diagram
随机推荐
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
中電資訊-信貸業務數字化轉型如何從星空到指尖?
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
Remember another interview trip to Ali, which ends on three sides
Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
Life cycle of instance variables, static variables and local variables
The automatic control system of pump station has powerful functions and diverse application scenarios
Global and Chinese market of thin film deposition systems 2022-2028: Research Report on technology, participants, trends, market size and share
Take you to master the formatter of visual studio code
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
Summarize the past to motivate yourself to move on
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
The difference between int (1) and int (10)
Redis transaction
There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection
Small program graduation project based on wechat reservation small program graduation project opening report reference
1189. Maximum number of "balloons"
ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel
Portapack application development tutorial (XVII) nRF24L01 launch C
High level application of SQL statements in MySQL database (I)