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// w  ww  .j  a  v  a2  s.  c  o  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;