- 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.
- Mobile Web Performance Optimization
- PHP基礎案例教程
- Mastering Swift 2
- The Professional ScrumMaster’s Handbook
- Scratch3.0趣味編程動手玩:比賽訓練營
- C# and .NET Core Test Driven Development
- Web前端應用開發(fā)技術
- ASP.NET求職寶典
- HTML5移動前端開發(fā)基礎與實戰(zhàn)(微課版)
- Web編程基礎:HTML5、CSS3、JavaScript(第2版)
- Web前端開發(fā)最佳實踐
- Software-Defined Networking with OpenFlow(Second Edition)
- 計算機組裝與維護(第二版)
- 面向對象程序設計及C++(第3版)
- 信息學奧林匹克競賽初賽精講精練