fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. interface Func<A> {
  11. double apply(Optional<A> a);
  12. }
  13.  
  14. public static double compute(Func<? super Double> f) {
  15. // Sometimes amend the function to do something slightly different
  16. Func<? super Double> g = f;
  17. if (System.currentTimeMillis() > 0)
  18. g = oa -> Math.max(0, f.apply(oa.map(a -> a)));
  19.  
  20. return g.apply(Optional.of(3.14)) + g.apply(Optional.empty());
  21. }
  22.  
  23. public static void main (String[] args) throws java.lang.Exception
  24. {
  25. Func<Double> f = oa -> 0;
  26. compute(f);
  27.  
  28. Func<Object> g = oa -> 0;
  29. compute(g);
  30. }
  31. }
Success #stdin #stdout 0.22s 33244KB
stdin
Standard input is empty
stdout
Standard output is empty