fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.function.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. final Test[] test = new Test[20];
  14. Supplier<Test> t = () -> test[10];
  15. test[10] = new Test(7);
  16. System.out.println(t.get().whatever);
  17. test[10] = new Test(42);
  18. System.out.println(t.get().whatever);
  19. }
  20. }
  21.  
  22. class Test {
  23. public Test(int i){this.whatever = i;}
  24. Integer whatever;
  25. }
Success #stdin #stdout 0.23s 320704KB
stdin
Standard input is empty
stdout
7
42