@Test public void reverse_elements_in_list_apache () { ReverseListIterator reverseListIterator = new ReverseListIterator(precipitation); List<String> reversePrecipitation = new ArrayList<String>(); while (reverseListIterator.hasNext()) { reversePrecipitation.add( (String) reverseListIterator.next()); } assertThat(reversePrecipitation, contains( "Drizzle", "Rain", "Freezing rain", "Freezing drizzle", "Ice crystals", "Hail", "Ice pellets", "Snow grains", "Snow")); }
private static void iterateReverseListIterator(List<String> list) { System.out.print("\nApache ReverseListIterator:\n"); Iterator<String> it = new ReverseListIterator(list); while (it.hasNext()) { System.out.println(it.next()); } }