- 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.
- Vue.js 3.x從入門到精通(視頻教學版)
- Asynchronous Android Programming(Second Edition)
- Tableau 10 Bootcamp
- Swift 4 Protocol-Oriented Programming(Third Edition)
- 一塊面包板玩轉Arduino編程
- Unity 3D腳本編程:使用C#語言開發跨平臺游戲
- Android Development Tools for Eclipse
- Drupal 8 Development Cookbook(Second Edition)
- Mastering Object:Oriented Python(Second Edition)
- Bitcoin Essentials
- Python深度學習入門:從零構建CNN和RNN
- Jenkins 2.x實踐指南
- 深入理解C++11:C++11新特性解析與應用
- Apple Watch極速開發
- 云原生基礎架構:構建和管理現代可擴展基礎架構的模式及實踐