fork download
  1. @FunctionalInterface
  2. interface Functional { void f(int a); }
  3.  
  4. class B {
  5. void GenerateData(Functional f) {
  6. f.f(12345);
  7. }
  8. }
  9.  
  10. class A {
  11. public void XXX() {
  12. B b = new B();
  13. b.GenerateData(this::ZZZ);
  14. }
  15. public void ZZZ(int n) {
  16. System.out.println("n = " + n);
  17. }
  18. }
  19.  
  20. class Main {
  21. public static void main(String[] args) {
  22. A a = new A();
  23. a.XXX();
  24. }
  25. }
  26.  
  27.  
Success #stdin #stdout 0.2s 33288KB
stdin
Standard input is empty
stdout
n = 12345