以下代码:
public static void main(String[] args) {
Collections.singleton(1).stream().forEach(i -> new Exception().printStackTrace());
}
打印:
java.lang.Exception
at PrintLambdaStackTrace.lambda$main$0(PrintLambdaStackTrace.java:6)
at PrintLambdaStackTrace$$Lambda$1/1831932724.accept(Unknown Source)
at java.util.Collections$2.tryAdvance(Collections.java:4717)
at java.util.Collections$2.forEachRemaining(Collections.java:4725)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at PrintLambdaStackTrace.main(PrintLambdaStackTrace.java:6)
如何实现lambda调用?为什么有2个堆栈帧?