, , , doFunc, , - . :
public interface IFunction {
public void execute(Object o);
}
, , IFunction, execute, .
public static void doFunc(List c, IFunction f) {
for (Object o : c) {
f.execute(o);
}
}
c , IFunction, execute, IFunction, c.
doFunc(numbers, new IFunction() {
public void execute(Object o) {
Integer anInt = (Integer) o;
anInt++;
System.out.println(anInt);
}
});
main , IFunction. - , - , execute, inline.
, IFunction, doFunc, - throwaway, , .