Java - Write code to check if a string starts With Any String value from an array using variable length parameter


Write code to starts With Any


//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String stringToMatch = "";
        String stringToCheckEquals = "";
        System.out//from   ww w.  j  av  a2  s.  co m
                .println(startsWithAny(stringToMatch, stringToCheckEquals));

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