Java - Write code to check if a string ends With Any other string in an array with for loop

Requirements

Write code to check if a string ends With Any other string in an array with for loop

Demo

//package com.book2s;

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

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

Related Example