### Question:
IteratorWithVariables implements Iterator { @Override public Object next() { Object obj = target.next(); index++; first = index == 0; last = !hasNext(); even = (index % 2) == 0; odd = !even; return obj; } IteratorWithVariables(boolean[] arr);  IteratorWithVariables(byte[] arr);  IteratorWithVariables(char[] arr);  IteratorWithVariables(short[] arr);  IteratorWithVariables(int[] arr);  IteratorWithVariables(long[] arr);  IteratorWithVariables(float[] arr);  IteratorWithVariables(double[] arr);  IteratorWithVariables(Object[] arr);  IteratorWithVariables(Stream stream);  IteratorWithVariables(Iterable iterable); @Override boolean hasNext(); @Override Object next(); public int index; public boolean first; public boolean last; public boolean even; public boolean odd; }### Answer:
@Test public void test() { List<String> all = asList("a", "b", "c"); Map<ForOfVariable, String> vars = new EnumMap<>(ForOfVariable.class); vars.put(ForOfVariable.index, "ii"); vars.put(ForOfVariable.first, "ff"); vars.put(ForOfVariable.last, "ll"); vars.put(ForOfVariable.odd, "oo"); vars.put(ForOfVariable.even, "ee"); IteratorWithVariables iter = new IteratorWithVariables(all); assertThat(iter.index).isEqualTo(-1); iter.next(); assertThat(iter.index).isEqualTo(0); assertThat(iter.even).isEqualTo(true); assertThat(iter.odd).isEqualTo(false); assertThat(iter.first).isEqualTo(true); assertThat(iter.last).isEqualTo(false); iter.next(); assertThat(iter.index).isEqualTo(1); assertThat(iter.even).isEqualTo(false); assertThat(iter.odd).isEqualTo(true); assertThat(iter.first).isEqualTo(false); assertThat(iter.last).isEqualTo(false); iter.next(); assertThat(iter.index).isEqualTo(2); assertThat(iter.even).isEqualTo(true); assertThat(iter.odd).isEqualTo(false); assertThat(iter.first).isEqualTo(false); assertThat(iter.last).isEqualTo(true); }