@Test void next_should_move_to_the_next_element_in_order_from_the_back_and_return_it() { ReversedIterable<String> reversedIterable = new ReversedIterable<>(Arrays.asList("a", "b", "c")); Iterator<String> iterator = reversedIterable.iterator(); Assertions.assertTrue(iterator.hasNext()); Assertions.assertEquals("c", iterator.next()); Assertions.assertEquals("b", iterator.next()); Assertions.assertEquals("a", iterator.next()); Assertions.assertFalse(iterator.hasNext()); }
@Override public Iterator<T> iterator() { return new ReversedIterator(); }
ReversedIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return new ReversedIterator(); } }
ReversedIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return new ReversedIterator(); } ReversedIterable(List<T> list); }
ReversedIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return new ReversedIterator(); } ReversedIterable(List<T> list); @Override Iterator<T> iterator(); }
ReversedIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return new ReversedIterator(); } ReversedIterable(List<T> list); @Override Iterator<T> iterator();  }