S.NO. | EXTERNAL ITERATION | INTERNAL ITERATION |
1. | Available before Java 8 too. | It is introduced in Java SE 8 |
2. | Iterating an Aggregated Object elements externally. | Iterating an Aggregated Object elements internally (background). |
3. | Iterate elements by using for-each loop and Iterators like Enumeration, Iterator, ListIterator. | Iterate elements by using Java API like “forEach” method. |
4. | Iterating elements in Sequential and In-Order only. | Not required to iterate elements in Sequential order. |
5. | It follows OOP approach that is Imperative Style. | It follows Functional Programming approach that is Declarative Style. |
6. | It does NOT separate responsibilities properly that is, it defines both “What is to be done” and “How it is to be done”. | It defines only “What is to be done”. No need to worry about “How it is to be done”. Java API takes care about “How to do”. |
7. | Less Readable Code. | More Readable code. |
No comments:
Post a Comment