package com.github.Avengers.larboratory;

import java.util.Iterator;

public class SimpleForEach implements Iterable<String> {

	private String[] str = {"tianlelu", "why", "write", "this"};

	public static void main(String[] args) {
		SimpleForEach simpleForEach = new SimpleForEach();
		for (String s : simpleForEach) {
			System.out.println(s);
		}
	}

	public Iterator iterator() {
		return new Iterator() {

			private int index = 0;

			public boolean hasNext() {
				return index < str.length;
			}

			public String next() {
				return str[index++];//不知道怎么写了
			}

			public void remove() {
				str = null;
			}

		};

	}
}



@@ -54,24 +54,74 @@
 va.util.
-Iterator
+Arrays;%0D%0Aimport java.util.Iterator;%0D%0Aimport java.util.List
 ;%0D%0A%0D%0Apub
@@ -306,27 +306,129 @@
 ch s
-impleForEach = new 
+trings = new SimpleForEach();%0D%0A%0D%0A%09%09strings.eachSimple(strings);%0D%0A%09%09strings.eachDemo();%0D%0A%0D%0A%09%7D%0D%0A%0D%0A%09private void eachSimple(
 Simp
@@ -436,19 +436,27 @@
 eForEach
-();
+ strings) %7B
 %0D%0A%09%09for 
@@ -472,23 +472,107 @@
  : s
-impleForEach) %7B
+trings)%0D%0A%09%09%09System.out.println(s);%0D%0A%09%7D%0D%0A%0D%0A%09private void eachDemo() %7B%0D%0A%09%09for (String s : new Demo())
 %0D%0A%09%09
@@ -596,21 +596,16 @@
 ln(s);%0D%0A
-%09%09%7D%0D%0A
 %09%7D%0D%0A%0D%0A%09p
@@ -660,18 +660,16 @@
 or() %7B%0D%0A
-%0D%0A
 %09%09%09priva
@@ -687,18 +687,16 @@
 x = 0;%0D%0A
-%0D%0A
 %09%09%09publi
@@ -712,30 +712,24 @@
  hasNext() %7B
-%0D%0A%09%09%09%09
 return index
@@ -742,21 +742,16 @@
 .length;
-%0D%0A%09%09%09
 %7D%0D%0A%0D%0A%09%09%09
@@ -772,22 +772,16 @@
 next() %7B
-%0D%0A%09%09%09%09
 return s
@@ -792,16 +792,17 @@
 ndex++%5D;
+%7D
 //%E4%B8%8D%E7%9F%A5%E9%81%93%E6%80%8E%E4%B9%88%E5%86%99
@@ -803,22 +803,16 @@
 %E4%B8%8D%E7%9F%A5%E9%81%93%E6%80%8E%E4%B9%88%E5%86%99%E4%BA%86%0D
-%0A%09%09%09%7D%0D
 %0A%0D%0A%09%09%09pu
@@ -835,41 +835,234 @@
 () %7B
-%0D%0A%09%09%09%09str = null;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%7D;%0D%0A
+str = new String%5B4%5D;%7D%0D%0A%09%09%7D;%0D%0A%09%7D%0D%0A%0D%0A%09class Demo implements Iterable%3CString%3E %7B%0D%0A%0D%0A%09%09private List elements = Arrays.asList(%22tianlelu%22, %22why%22, %22write%22, %22this%22);%0D%0A%0D%0A%09%09public Iterator%3CString%3E iterator() %7Breturn elements.iterator();%7D
 %0D%0A%09%7D

add demo of list forEach