fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.function.*;
  5. import java.lang.*;
  6. import java.lang.reflect.*;
  7. import java.io.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main(String[] args) throws Exception {
  13. int i = 123;
  14. String s = "asdf";
  15. printCaptures(x -> x + i + s);
  16. }
  17.  
  18. static void printCaptures(Function<Integer, String> f) throws Exception {
  19. System.out.println(f.getClass());
  20. for (Field field : f.getClass().getDeclaredFields()) {
  21. field.setAccessible(true);
  22. System.out.println(field.getName() + ": " + field.get(f));
  23. }
  24. }
  25. }
Success #stdin #stdout 0.18s 2841600KB
stdin
Standard input is empty
stdout
class Ideone$$Lambda$1/1324119927
arg$1: 123
arg$2: asdf