mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 02:16:06 +00:00
Added comments for iterator example.
This commit is contained in:
1 parent
4fef18f6c6
commit
40e5444718
3 files changed
+17
No files matched your search
@@ -1,5 +1,12 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Iterator (ItemIterator) adds abstraction layer on top of a
|
||||||
|
* collection (TreasureChest). This way the collection can change
|
||||||
|
* its internal implementation without affecting its clients.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class App
|
public class App
|
||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Iterator interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface ItemIterator {
|
public interface ItemIterator {
|
||||||
|
|
||||||
boolean hasNext();
|
boolean hasNext();
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ package com.iluwatar;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Collection class.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class TreasureChest {
|
public class TreasureChest {
|
||||||
|
|
||||||
private List<Item> items;
|
private List<Item> items;
|
||||||
|
|||||||
Reference in new issue
Block a user