Write code to starts With Any
//package com.book2s; public class Main { public static void main(String[] argv) { String stringToMatch = "book2s.com"; String stringToCheckEquals = "book2s.com"; 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; } }