fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.lang.*;
  6. import java.io.*;
  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. Stream test = Arrays.asList(1, 2, 3)
  14. .stream();
  15. test.findFirst();
  16. test.forEach(x->System.out.println("HI!"));
  17. }
  18. }
Runtime error #stdin #stdout #stderr 0.25s 320832KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.IllegalStateException: stream has already been operated upon or closed
	at java.util.stream.AbstractPipeline.sourceStageSpliterator(AbstractPipeline.java:274)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at Ideone.main(Main.java:16)