Java How does this interface code actually work?
<p>I've put together the code below using ideas giving to me by fellow members and then changing a couple of the containers. For the life of me i cant really get my head around some of this. The reason for the code is that i wished to pass a function as a parameter. The part of code i especially don't understand is:</p>

<pre><code>doFunc(numbers, new IFunction() { 
    public void execute(Object o) { 
       Integer anInt = (Integer) o; 
       anInt++;
       System.out.println(anInt);
    } 
}); 
</code></pre>

<p>I understand to some extent that we're using an interface to represent a function using an object (i think?). This is the full code:</p>

<pre><code>public static void main(String[] args) {
    Integer[] strArray = new Integer[]{1,2,3,4,5};

    List numbers = Arrays.asList(strArray);
    doFunc(numbers, new IFunction() { 
        public void execute(Object o) { 
           Integer anInt = (Integer) o; 
           anInt++;
           System.out.println(anInt);
        } 
    }); 
    for(int y =0; y&lt;numbers.size();y++){
        System.out.println(numbers.get(y));
    }
}

public static void doFunc(List c, IFunction f) { 
   for (Object o : c) { 
      f.execute(o); 
   } 
}

public interface IFunction { 
    public void execute(Object o); 
} 
</code></pre>

<p>I guess i just need someone to go a little slower explaining it. Thanks for bearing with me.</p>
