Java Utililty Methods List IndexOf

List of utility methods to do List IndexOf

Description

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

Method

intindexOfId(List aList, Object anObj)
Returns index of identical given object in given list.
for (int i = 0, iMax = size(aList); i < iMax; i++)
    if (anObj == aList.get(i))
        return i;
return -1;
intindexOfIdentical(List list, Object value)
Returns the index in list of the first occurrence identical to value , or -1 if list does not contain value .
int i = 0;
for (Object element : list) {
    if (element == value) {
        return i;
    ++i;
return -1;
...
intindexOfIdentity(List l, T t)
index Of Identity
for (int i = 0; i < l.size(); i++) {
    if (l.get(i) == t)
        return i;
return -1;
intindexOfIgnoreCase(List values, String target)
index Of Ignore Case
for (int i = 0; i < values.size(); i++) {
    if (values.get(i).equalsIgnoreCase(target)) {
        return i;
return -1;
intindexOfInstance(List list, Object object)
Performs a lookup for the exact instance of an object in the list and returns its index, or -1 if not found.
for (int i = 0; i < list.size(); i++) {
    if (list.get(i) == object) {
        return i;
return -1;
intindexOfInstance(List list, Class type)
Finds the index of the first element in the given list of the given type.
int k = 0;
for (T t : list) {
    if (type.isInstance(t)) {
        return k;
    k++;
return -1;
...
intindexOfMax(List list)
index Of Max
return list.indexOf(Collections.max(list));
intindexOfMax(List list)
Finds the first index of a maximal element in a list.
T min = list.get(0);
int index = 0;
for (int i = 0, n = list.size(); i < n; i++) {
    T value = list.get(i);
    if (value.compareTo(min) > 0) {
        min = value;
        index = i;
return index;
intindexOfMinSize(final List> sets)
index Of Min Size
if (sets.isEmpty())
    throw new IllegalArgumentException("empty sets");
int res = 0;
for (int i = 1; i < sets.size(); i++) {
    if (sets.get(i).size() < sets.get(res).size())
        res = i;
return res;
...
intindexOfNull(List list)
Returns the index of the first null element within the given List .
int retval = -1;
if (list != null) {
    retval = list.indexOf(null);
return retval;