Java - Write code to check if a string contains Any other string in an array using Stream

Requirements

Write code to contains Any

Demo

//package com.book2s;
import java.util.Arrays;

public class Main {
  public static void main(String[] argv) {
    String str = "book2s.com";
    String searchStrings = "o";
    System.out.println(containsAny(str, searchStrings));
  }//from ww w . j a v  a2 s .  c  o m

  public static boolean containsAny(final String str, final String... searchStrings) {
    return Arrays.stream(searchStrings).anyMatch(s -> str.contains(s));
  }
}