Java Utililty Methods ListIterator Usage

List of utility methods to do ListIterator Usage

Description

The list of methods to do ListIterator Usage are organized into topic(s).

Method

ListinternStringsInList(List list)
This method interns all the strings in the given list in place.
if (list != null) {
    try {
        ListIterator<String> it = list.listIterator();
        while (it.hasNext()) {
            it.set(it.next().intern());
    } catch (UnsupportedOperationException e) {
return list;
booleanisEqual(java.util.List list1, java.util.List list2)
is Equal
ListIterator e1 = list1.listIterator();
ListIterator e2 = list2.listIterator();
while (e1.hasNext() && e2.hasNext()) {
    Object o1 = e1.next();
    Object o2 = e2.next();
    if (!(o1 == null ? o2 == null : o1.equals(o2)))
        return false;
return !(e1.hasNext() || e2.hasNext());
TiteratorBinarySearchGet(ListIterator i, int index)
Gets the ith element from a list by repositioning the specified list's ListIterator.
T obj = null;
int pos = i.nextIndex();
if (pos <= index) {
    do {
        obj = i.next();
    } while (pos++ < index);
} else {
    do {
...
intlastIndexOf(List list, T element)
Returns the last index of a specific elemen in a list.
ListIterator<? super T> iter = list.listIterator();
int index = -1;
while (iter.hasNext()) {
    Object t = iter.next();
    if (element.equals(t)) {
        index = iter.previousIndex();
return index;
booleanlistEquals(List left, List right)
list Equals
if (left == right)
    return true;
ListIterator<T> leftIterator = left.listIterator();
ListIterator<T> rightIterator = right.listIterator();
while (leftIterator.hasNext() && rightIterator.hasNext()) {
    T leftElement = leftIterator.next();
    T rightElement = rightIterator.next();
    if (!(leftElement == null ? rightElement == null : leftElement.equals(rightElement)))
...
booleanlistHasIdentContent(List list_1, List list_2)
list Has Ident Content
if (list_1 == list_2)
    return true;
if (list_1.size() != list_2.size())
    return false;
ListIterator<?> e1 = list_1.listIterator();
ListIterator<?> e2 = list_2.listIterator();
while (e1.hasNext() && e2.hasNext()) {
    Object o1 = e1.next();
...
String[]listToStringArray(java.util.List list)
Get the values from specified list and return them as a string array.
if (list == null)
    return null;
String[] result = new String[list.size()];
ListIterator iterator = list.listIterator();
int i = 0;
while (iterator.hasNext()) {
    result[i] = (String) iterator.next();
    i++;
...
StringmakeSortFieldFallbackExpr(List fieldNames)
make Sort Field Fallback Expr
if (fieldNames.size() == 0)
    return null;
ListIterator<String> it = fieldNames.listIterator(fieldNames.size());
String expr = it.previous();
while (it.hasPrevious()) {
    String fieldName = it.previous();
    expr = makeIfExistsExpr(fieldName, fieldName, expr);
return expr;
StringnormalizeVersion(String version, int length)
Normalizes a version string so that it has 'length' number of version numbers separated by '.'
if (version == null) {
    return null;
List<String> numbers = new ArrayList<String>(Arrays.asList(version.split("\\.")));
while (numbers.size() < length) {
    numbers.add("0");
StringBuilder builder = new StringBuilder();
...
int[]numberToDigits(int num)
number To Digits
if (num < 0) {
    throw new IllegalArgumentException("num should not be negative");
final int RADIX = 10;
List<Integer> list = new ArrayList<Integer>();
while (num > 0) {
    list.add(num % RADIX);
    num /= RADIX;
...