fork(1) download
  1. import java.util.function.*;
  2.  
  3. class Foo
  4. {
  5. private int x = 0;
  6.  
  7. Foo setX(int x) {
  8. this.x = x;
  9. return this;
  10. }
  11.  
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. Foo foo = new Foo();
  15.  
  16. Consumer<Integer> setX = foo::setX;
  17. setX.accept(3);
  18.  
  19. System.out.println(foo.x);
  20. }
  21. }
Success #stdin #stdout 0.07s 32976KB
stdin
Standard input is empty
stdout
3