Java Utililty Methods List Last Item

List of utility methods to do List Last Item

Description

The list of methods to do List Last Item are organized into topic(s).

Method

ListaddDelimiter(List lines, String delimiter, boolean isDelimitedLastLine)
add Delimiter
int amountLines = lines.size();
int index = 0;
for (String line : lines) {
    line = line.trim();
    boolean isLastLine = index + 1 == amountLines;
    if (!isLastLine || isDelimitedLastLine) {
        if (!line.endsWith(delimiter)) {
            line = line + delimiter;
...
voidaddLast(T e, List list)
Add the element to the last position of a list.
list.add(e);
voidaddLastElement(List list, T element)
add Last Element
list.add(list.size(), element);
StringbuildPathFromComponentsUpToIndex(final List pathComponents, final int lastIndex)
Given a list of path components, as produced by the breakIRODSPathIntoComponents, re-create an iRODS absolute path by simply stringing together the path components with the iRODS '/' delimiter.
if (pathComponents == null) {
    throw new IllegalArgumentException("null pathComponents");
StringBuilder sb = new StringBuilder();
int i = 0;
for (String pathComponent : pathComponents) {
    if (!pathComponent.isEmpty()) {
        if (lastIndex >= 0) {
...
byte[]flattenByteSegments(List byteSegments, int eachSegmentButLastLength, int lastSegmentLength)
Turns a List of equally-sized byte segments (buffers) into a single buffer by concatenating them one by one.
if (byteSegments.isEmpty())
    return new byte[0];
else {
    int totalBytes = eachSegmentButLastLength * (byteSegments.size() - 1) + lastSegmentLength;
    byte[] flattenedBytes = new byte[totalBytes];
    int nextSegmentOffset = 0;
    for (int i = 0; i < byteSegments.size() - 1; i++) {
        System.arraycopy(byteSegments.get(i), 0, flattenedBytes, nextSegmentOffset,
...
TgetLast(final List list)
Gets the last element of the list.
if (list == null || list.isEmpty()) {
    return null;
} else {
    return list.get(list.size() - 1);
TgetLast(final List list)
Gets the last object from the given List.
if (!isEmpty(list) && 0 < list.size()) {
    return list.get(list.size() - 1);
return null;
EgetLast(List list)
Returns the last element of a list or null, if empty.
if (list.isEmpty()) {
    return null;
return list.get(list.size() - 1);
TgetLast(List aList)
Returns the last object in the given list.
return get(aList, size(aList) - 1);
TgetLast(List elements)
get Last
return elements.get(elements.size() - 1);