Write code to check if a string ends With Any other string in an array with for loop
//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)); }// www . j av a 2 s . co m public static boolean endsWithAny(String stringToMatch, String... stringToCheckEquals) { for (final String candidate : stringToCheckEquals) { if (stringToMatch.endsWith(candidate)) { return true; } } return false; } }