Java Utililty Methods List Ends with

List of utility methods to do List Ends with

Description

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

Method

booleanendsWith(List left, List right, boolean equals)
ends 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(l - i - 1), right.get(r - i - 1)))
...
booleanendsWith(List left, List right, boolean equals)
ends 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(l - i - 1), right.get(r - i - 1))) {
            return false;
    return true;
booleanendsWith(List source, List prefix)
ends With
return endsWith(source, prefix, 0);
booleanendsWith(List hierarchy, String... items)
Check that the provided list ends with the provided items
if (hierarchy.size() < items.length) {
    return false;
final int firstI = hierarchy.size() - items.length;
for (int i = firstI; i < hierarchy.size(); i++) {
    if (!hierarchy.get(i).equals(items[i - firstI])) {
        return false;
return true;
booleanendsWith(List lst, List suffix)
Checks if list ends with the specific suffix
int idx = lst.size() - suffix.size();
if (idx < 0) {
    return false;
for (int i = 0; i < suffix.size(); i++) {
    if (!lst.get(idx + i).equals(suffix.get(i))) {
        return false;
return true;
booleanendsWith(List string, List suffix)
Checks if the list ends with specific elements.
final int stringSize = string.size();
final int suffixSize = suffix.size();
if (suffixSize > stringSize) {
    return false;
return suffix.equals(string.subList(stringSize - suffixSize, stringSize));