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
1, Review of knowledge points
1. Java generics < >
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 >.
The data type cannot be a native ...
Added by anon_amos on Tue, 08 Feb 2022 04:57:05 +0200
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
Added by zab329 on Fri, 24 Dec 2021 00:18:25 +0200
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