Java - Write code to check if a string contains Any Of another string using variable length method

Requirements

Write code to check if a string contains Any Of another string using variable length method

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String stringToMatch = "book2s.com";
        String candidates = "book2s.com";
        System.out.println(containsAnyOf(stringToMatch, candidates));
    }//w ww  . ja  va 2s  .  c  o  m

    public static String containsAnyOf(String stringToMatch,
            String... candidates) {
        for (final String candidate : candidates) {
            if (stringToMatch.contains(candidate)) {
                return candidate;
            }
        }
        return null;
    }
}