diff --git a/src/main/java/com/msb/iterator/v4/Main.java b/src/main/java/com/msb/iterator/v4/Main.java index 9db4aa0..ee6ed35 100644 --- a/src/main/java/com/msb/iterator/v4/Main.java +++ b/src/main/java/com/msb/iterator/v4/Main.java @@ -21,7 +21,8 @@ public class Main { Iterator_ iterator = list.iterator(); while (iterator.hashNext()) { - System.out.println(iterator.next()); + Dog dog = (Dog) iterator.next(); + System.out.println(dog); } } } diff --git a/src/main/java/com/msb/iterator/v5/Main.java b/src/main/java/com/msb/iterator/v5/Main.java index 67122d4..cde67e9 100644 --- a/src/main/java/com/msb/iterator/v5/Main.java +++ b/src/main/java/com/msb/iterator/v5/Main.java @@ -16,14 +16,15 @@ import com.msb.iterator.v4.Dog; */ public class Main { public static void main(String[] args) { - Collection_ list = new LinkedList_(); + Collection_ list = new LinkedList_(); for (int i=0; i<15; i++) { list.add(new Dog(i)); } - Iterator_ iterator = list.iterator(); + Iterator_ iterator = list.iterator(); while (iterator.hashNext()) { - System.out.println(iterator.next()); + Dog dog = iterator.next(); + System.out.println(dog); } } }