Add java8-features module: runnable demos and captured output for the ankurm.com java8-features article
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/** Fails to compile on purpose: a lambda may only capture effectively final locals. */
|
||||
public class CaptureError {
|
||||
public static void main(String[] args) {
|
||||
int counter = 0;
|
||||
Supplier<Integer> s = () -> counter;
|
||||
counter++;
|
||||
System.out.println(s.get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user