fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.function.*;
  5.  
  6. class Ideone {
  7. static class Wrapper {
  8. public Integer a;
  9. }
  10.  
  11. public static void main (String[] args) throws java.lang.Exception {
  12. Wrapper w = new Wrapper();
  13. w.a = 9;
  14.  
  15. Consumer<Integer> f = (Integer b) -> {
  16. System.out.println(w.a + b);
  17. w.a = 7; // Allowed
  18. };
  19.  
  20. f.accept(10);
  21. f.accept(10);
  22. w.a = 3; // Allowed
  23. f.accept(10);
  24. }
  25. }
Success #stdin #stdout 0.22s 320704KB
stdin
Standard input is empty
stdout
19
17
13