There is a Outer lambda that contains inner lambda whis tries to reference var in Outer lambda, how does it possible? Im try to understand what this expression will look like when its compiled to make this possible.
public static void main(String[] args) {
ExecutorService service = Executors.newScheduledThreadPool(10);
DoubleStream.of(3.14159, 2.71828)
.forEach(c -> service.submit(
() -> System.out.println(c)));
I'm guess is will compiled to something like this:
new Consumer<Double>() {
@Override
public void accept(Double aDouble) {
new Runnable() {
@Override
public void run() {
System.out.println(aDouble);
}
};
}
};
Am i right?