I have Arrayand you want to do some mapping with it.
I found out that this can be done in two ways in java 8:
String[] alphabet = new String[]{"A", "B", "C"};
anyMatch:
Arrays.stream(alphabet).anyMatch("A"::equalsIgnoreCase)
findAny:
Arrays.stream(alphabet).filter("a"::equalsIgnoreCase).findAny().orElse("No match found"))
As I understand it, both are doing the same job. However, I could not find which one was preferable?
Can anyone clarify the difference between the two?
source
share