1 2 3 4 5 6 7 8 9 10 11 12 13 14
import lombok.var; public class VarInFor { public VarInFor() { super(); } public void enhancedFor() { int[] list = new int[]{1, 2}; for (@var int shouldBeInt : list) { System.out.println(shouldBeInt); @var int shouldBeInt2 = shouldBeInt; } } }