Created
August 20, 2009 11:20
-
-
Save NicolasT/170997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Function1<T1, R> { | |
public R apply(T1 v); | |
} | |
public class Functional { | |
public static void main(String[] args) { | |
Integer[] i = {1, 2, 3, 4}; | |
foreach(new Function1<Integer, Object>() { | |
public Object apply(Integer v) { | |
System.out.println("" + v); | |
return null; | |
} | |
}, i); | |
} | |
private static <T> void foreach(Function1<T, Object> fun, T[] values) { | |
for(T o: values) { | |
fun.apply(o); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment