I have this list ["z", "1", "3", "x", "y", "00", "x", "y", "4"] that I need to get the first Integer element after the String 00 in this case 4. I am using Java 8 streams but any other method is welcome. Here is my starter code
myList.stream()
// Remove any non-Integer characters
.filter((str) -> !"x".equals(str) && !"y".equals(str) && !"z".equals(str))
.findFirst()
.orElse("");
That starts me off by removing all non-Integer Strings but gives me 1. Now what I need is to get 4 which is the first element after 00. What should I add to the filter?
dropWhileand continue using filter with Java-9+ as inmylist.stream().dropWhile(s -> !s.equals("00")).filter..., but what matters is the problem statement being specific about getting the integers and that too after a pattern00.