Java Utililty Methods List Starts with

List of utility methods to do List Starts with

Description

The list of methods to do List Starts with are organized into topic(s).

Method

booleanstartsWith(List left, List right, boolean equals)
starts With
if (left == null || right == null)
    return false;
int l = left.size();
int r = right.size();
if (r > l || !equals && r == l)
    return false;
for (int i = 0; i < r; i++)
    if (!equals(left.get(i), right.get(i)))
...
booleanstartsWith(List left, List right, boolean equals)
starts With
if (left == null || right == null) {
    return false;
} else {
    int l = left.size();
    int r = right.size();
    if (r > l || !equals && r == l) {
        return false;
    for (int i = 0; i < r; i++) {
        if (!equals(left.get(i), right.get(i))) {
            return false;
    return true;
booleanstartsWith(List list0, List list1)
Returns whether one list is a prefix of another.
return list0.equals(list1) || list0.size() > list1.size() && list0.subList(0, list1.size()).equals(list1);
booleanstartsWith(List string, List prefix)
Checks if the list starts with specific elements.
final int stringSize = string.size();
final int prefixSize = prefix.size();
if (prefixSize > stringSize) {
    return false;
return prefix.equals(string.subList(0, prefixSize));
booleanstartsWithAny(String s, List prefixes)
Tests whether a string starts with any of a list of strings.
int count = prefixes.size();
for (int i = 0; i < count; ++i) {
    if (s.startsWith((String) prefixes.get(i))) {
        return true;
return false;
booleanstartsWithWord(String aTarget, List aExpectWordList)
starts With Word
for (String tCurrentExpectWord : aExpectWordList) {
    if (aTarget.startsWith(tCurrentExpectWord))
        return true;
return false;