- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 122字
- 2021-06-25 20:52:38
Applicability and examples
Iterators are popular in most programming languages these days. It is probably most widely used in Java, along with the collections package. It is also implemented at the language level when a collection is traversed with the following loop construction:
for (String item : strCollection)
System.out.println(item);
The iterator pattern can be implemented using the generics mechanism. This way, we can make sure we can avoid runtime errors generated by forced castings.
Good practice when implementing new containers and iterators in Java is to implement the existing java.util.Iterator<E> and java.util.Collection<E> classes. When we need aggregators with specific behaviors, we should also consider extending one of the classes that were implemented in the java.collection package instead of creating a new one.
- 大學計算機基礎(第二版)
- Mastering Ext JS(Second Edition)
- 大話PLC(輕松動漫版)
- OpenDaylight Cookbook
- 精通JavaScript+jQuery:100%動態網頁設計密碼
- LabVIEW Graphical Programming Cookbook
- 華為HMS生態與應用開發實戰
- JavaScript前端開發與實例教程(微課視頻版)
- JavaScript:Moving to ES2015
- PLC編程與調試技術(松下系列)
- Apache Kafka Quick Start Guide
- 深入淺出React和Redux
- Python算法詳解
- 移動增值應用開發技術導論
- Java程序設計與項目案例教程