Enhanced for loop usage
1、 Enhanced for loop
Enhance the function of the for loop: simplify the writing format of the iterator. (Note: enhancing the bottom layer of the for loop still uses iterator traversal.) Scope of application of enhanced for loop: if it is an object or array object that implements the iteratable interface, you can use enhanced for loop. Disadvantages of enhancing the for loop: the effect of enhancing the for loop and iterator traversal is the same, that is, enhancing the internal of the for loop is implemented by calling iterator, but there are some disadvantages of enhancing the for loop, such as unable to dynamically delete the set content in the enhanced loop, unable to obtain subscripts, etc.
2、 Enhanced for loop format:
For (data type variable name: traversal target) {/ / data type variable name: declare a variable to receive the element traversed by the traversal target
}