ERROR - java.lang.IllegalArgumentException: [-1] at java.util.stream.ReferencePipeline.skip

Error

Exception in thread java.lang.IllegalArgumentException: [-1]
at java.util.stream.ReferencePipeline.skip(ReferencePipeline.java:407)

Error Type


RunTime Time ( Java 8 )


Sample Code


intList.stream().skip(-1).forEach(p->System.out.println(p));

Cause

Stream Skip method expects a positive argument.  


Resolution

Modify the Lambda body to return boolean instead of char.   

intList.stream().skip(0).forEach(p->System.out.println(p));