Java - Write code to check if a string equals to Any string inside an String array

Requirements

Write code to check if a string equals to Any string inside an String array

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String stringToMatch = "book2s.com";
        String stringToCheckEquals = "book2s.com";
        System.out.println(equalsAny(stringToMatch, stringToCheckEquals));
    }//from  w  ww  .j a va  2 s  . c  om

    public static boolean equalsAny(String stringToMatch,
            String... stringToCheckEquals) {
        for (final String candidate : stringToCheckEquals) {
            if (stringToMatch.equals(candidate)) {
                return true;
            }
        }
        return false;
    }
}

Related Exercise