字符串以任何Iterable开头
// 来自 N o w J a v a . c o m - 时代Java //package com.nowjava; public class Main { /** * @param stringList iterable of possible starting words * @param str String to be examined * @return true if str starts with any of the Strings in startArray, false otherwise. */ public static boolean startsWithAny(Iterable<String> stringList, String str) { return getStartingIndex(stringList, str) != -1; } /** * @param stringList iterable of possible starting words * @param examinedString String to be examined * @return index of first matching element in startArray if matched, -1 otherwise */ public static int getStartingIndex(Iterable<String> stringList, String examinedString) { int i = 0; for (String string : stringList) {