import java.util.function.*; public class UnnamedVariables { void testParameter(int _, String _) { System.out.println(_); } int _ = 123; String s = _; void testLambda() { Consumer consumer = _ -> System.out.println("Hello"); Consumer consumer2 = _ -> System.out.println(_); Consumer consumer3 = _ -> System.out.println(_.trim()); Consumer consumer4 = _ -> { var v = _; System.out.println(v.trim()); }; BiConsumer consumer5 = (_,_) -> {}; } void testWhen(Object obj) { switch (obj) { case String _ when _.isEmpty() -> {} } } void testLocal() { int _ = 10; int _ = 20; int _[] = {30}; int[] _ = {40}; var _ = "string"; for (int _ = 1;;) {} } void testNoInitializer() { int _; for(int _;;) {} } void testCatch() { try { System.out.println(); } catch (Exception _) { System.out.println("ignore"); } catch (Error _) { int _ = 1; for(int _:new int[10]) { System.out.println("oops"); } } } }