Add java8-features module: runnable demos and captured output for the ankurm.com java8-features article

This commit is contained in:
2026-10-20 17:13:58 +00:00
parent d565be93c6
commit 77c782abbf
18 changed files with 250 additions and 0 deletions
+11
View File
@@ -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());
}
}
+7
View File
@@ -0,0 +1,7 @@
/** Fails to compile on purpose: two default methods with the same signature and no override. */
public class DiamondError {
interface A { default String move() { return "a"; } }
interface B { default String move() { return "b"; } }
static class C implements A, B { }
public static void main(String[] args) { System.out.println(new C().move()); }
}