package org.think.ex;

interface InterfaceU {
	public void funcA();
	
	public void funcB();
	
	public void funcC();
}

class Execise22A {
	
	public InterfaceU makeInterfaceU() {
		return new InterfaceU() {
			public void funcA () {
				System.out.println("Anoymous Class funcA");
			}
			
			public void funcB () {
				System.out.println("Anoymous Class funcB");
			}
			
			public void funcC () {
				System.out.println("Anoymous Class funcC");
				Execise22A.this.invoke();
			}
		}; // must have a ';'
	}
	
	public void invoke() {
		System.out.println("Execise22A invoke");
	}
}

class Execise22B {
	
	public Execise22B () {
		
		arInterfaces = new InterfaceU[16];
	}
	
	public void addInterface(InterfaceU varInterface) {
		if (arInterfaces.length >= 16) {
			return;
		}
		else {
			arInterfaces[arInterfaces.length -1] = varInterface;
		}
	}
	
	public void clearInterface(int i) {
		if (i >= arInterfaces.length) {
			return;
		}
		arInterfaces[i] = null;
	}
	
	public void walkAll () {
		for (int i = 0; i < arInterfaces.length; i++) {
			arInterfaces[i].funcA();
			arInterfaces[i].funcB();
			arInterfaces[i].funcC();
		}
	}
	 

	private InterfaceU[] arInterfaces;

}

public class ExInnerClassU {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Execise22A arExercizeA[] = new Execise22A[12];
		Execise22B varExercizeB = new Execise22B();
		for (Execise22A varA : arExercizeA) {
			varExercizeB.addInterface(varA.makeInterfaceU());
		}
		
	}

}

@@ -129,24 +129,55 @@
 cise22A %7B%0A%09%0A
+%09public Execise22A() %7B%0A%09%09%0A%09%7D%0A%09%0A
 %09public Inte
@@ -692,16 +692,30 @@
 eU%5B16%5D;%0A
+%09%09iCount = 0;%0A
 %09%7D%0A%09%0A%09pu
@@ -770,16 +770,26 @@
 %7B%0A%09%09if (
+iCount %3E= 
 arInterf
@@ -803,14 +803,8 @@
 ngth
- %3E= 16
 ) %7B%0A
@@ -847,30 +847,16 @@
 ces%5B
-arInterfaces.length -1
+iCount++
 %5D = 
@@ -910,66 +910,71 @@
 ace(
-int i
 ) %7B%0A%09%09i
-f (i %3E= arInterfaces.length) %7B%0A%09%09%09return;%0A%09%09%7D%0A
+nt iSize = iCount;%0A%09%09for (int i = 0; i %3C iSize; i++) %7B%0A%09
 %09%09ar
@@ -995,16 +995,33 @@
 = null;%0A
+%09%09%09iCount--;%0A%09%09%7D%0A
 %09%7D%0A%09%0A%09pu
@@ -1085,32 +1085,85 @@
 .length; i++) %7B%0A
+%09%09%09if (arInterfaces%5Bi%5D == null) %7B%0A%09%09%09%09continue;%0A%09%09%09%7D%0A
 %09%09%09arInterfaces%5B
@@ -1276,16 +1276,39 @@
 erfaces;
+%0A%09%0A%09private int iCount;
 %0A%0A%7D%0A%0Apub
@@ -1425,16 +1425,18 @@
 ecise22A
+%5B%5D
  arExerc
@@ -1439,18 +1439,16 @@
 xercizeA
-%5B%5D
  = new E
@@ -1462,16 +1462,107 @@
 2A%5B12%5D;%0A
+%09%09for (int i = 0; i %3C arExercizeA.length; i++) %7B%0A%09%09%09arExercizeA%5Bi%5D = new Execise22A();%0A%09%09%7D%0A
 %09%09Execis
@@ -1696,16 +1696,42 @@
 ));%0A%09%09%7D%0A
+%09%09varExercizeB.walkAll();%0A
 %09%09%0A%09%7D%0A%0A%7D

fix null ptr error