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 Functional f;
  12. public void XXX() {
  13. B b = new B();
  14. b.GenerateData(this::ZZZ);
  15. }
  16. public void ZZZ(int n) {
  17. System.out.println("n = " + n);
  18. }
  19. }
  20.  
  21. class Main {
  22. public static void main(String[] args) {
  23. A a = new A();
  24. a.XXX();
  25. }
  26. }
  27.  
Success #stdin #stdout 0.21s 33300KB
stdin
Standard input is empty
stdout
n = 12345