I want to have a reversed list view on a list (in a similar way than List#sublist
provides a sublist view on a list). Is there some function which provides this
For small sized list we can create LinkedList
and then can make use of descending iterator as:
List stringList = new ArrayList<>(Arrays.asList("One", "Two", "Three"));
stringList.stream().collect(Collectors.toCollection(LinkedList::new))
.descendingIterator().
forEachRemaining(System.out::println); // Three, Two, One
System.out.println(stringList); // One, Two, Three