I am trying to do following:
1) get elements from collection that holds condition 2) sort it based on length 3) return only elements with max length
So for example
List<String> list = new ArrayList();
list.add("xone");
list.add("two");
list.add("xthree");
list.add("xseven");
Using stream i can create:
list.stream()
.filter( e -> e.startsWith("x"))
.sort( e -> e.length() )
.collect(..)
however this just sorts it.. is there any pretty way how to return only elements with maximum found length? In this case it would be "xthree" and "xseven"
Thanks for help!