foreach, Iterable and Iterator
foreach
According to the official documents, foreach syntax (sugar) appears to replace the iterator iteration of a collection. The purpose is to make the code beautiful and reduce errors. Started with java 1.5. Official website link: https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html
Note: the Collection Interface ( ...
Added by dionyssos on Wed, 09 Feb 2022 23:52:34 +0200
Comprehensive practical training of Java generics, collection framework, List interface, Iterator and Collections tool classes
1, Review of knowledge points
1. Java generics < >
Concept:
Generics are used to specify the data type you want to use. Angle brackets < > are used to indicate that the data type must be class.
For example, a Worker class is created and used as a generic type, < student >.
be careful:
The data type cannot be a native ...
Added by anon_amos on Tue, 08 Feb 2022 04:57:05 +0200
You must know the iterator and generator
generator is a special iterator, which can replace the implementation of iterator to make the code more conciseWhat is an iteratorAn iterator is called an iterator. It is an object used to help traverse a data structure. This object needs to comply with the iterator protocol.The iterator protocol requires the implementation of the next method, ...
Added by scott56hannah on Tue, 28 Dec 2021 01:35:14 +0200
js - various for loop analysis
The three most used structures in our development are: sequential structure, selection structure and circular structure. There are various loop structures in JavaScript, such as the most common for loop, forEach loop, for... In loop and for... of loop; of course, there are other loops such as while, but this article only discusses various for l ...
Added by zab329 on Fri, 24 Dec 2021 00:18:25 +0200
generator, iterable and iterator are confused
generator, iterable and iterator are confused
Through the list generation formula, we can directly create a list. However, due to memory constraints, the list capacity must be limited. Moreover, creating a list containing 1 million elements not only takes up a lot of storage space, but if we only need to access the first few elements, the spac ...
Added by killfall on Fri, 26 Nov 2021 15:58:55 +0200