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.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone {
  11. public static void main(Consumer<String> c) {
  12. c.accept(c.toString());
  13. }
  14. static PrintStream fakeOut = new PrintStream(System.out){
  15. @Override public void println(String x) {
  16. super.println("[FakeOut] " + x);
  17. }
  18. };
  19. public static void main(String[] args) {
  20. Consumer<String> consumerRef = System.out::println;
  21. Consumer<String> consumer = x -> System.out.println(x);
  22. main(consumerRef);
  23. main(consumer);
  24. System.setOut(fakeOut);
  25. main(consumerRef);
  26. main(consumer);
  27. }
  28. }
Success #stdin #stdout 0.2s 33328KB
stdin
Standard input is empty
stdout
Ideone$$Lambda$1/1078694789@448139f0
Ideone$$Lambda$2/1747585824@7cca494b
Ideone$$Lambda$1/1078694789@448139f0
[FakeOut] Ideone$$Lambda$2/1747585824@7cca494b