Java List Contain containsType(List list, Class type)

Here you can find the source of containsType(List list, Class type)

Description

contains Type

License

Apache License

Declaration

public static boolean containsType(List<?> list, Class type) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static boolean containsType(List<?> list, Class type) {
        return (indexOfType(list, type) != -1);
    }//from ww w . j  a va 2s.c  o  m

    public static int indexOfType(List<?> list, Class type) {
        for (int idx = 0; idx < list.size(); idx++) {
            if (type.isInstance(list.get(idx))) {
                return idx;
            }
        }
        return -1;
    }
}

Related

  1. containsReference(List references, Object toBeFound)
  2. containsSameItemsInOrder(List col1, List col2)
  3. containsStr(List list, String str)
  4. containsStringStartingWith(List list, String prefix)
  5. containsSubsequence(List a, List b)
  6. containsUnorderedSequence(List a, List b)
  7. containsUsingToArray(List list, Integer value)
  8. containsWhitespace(List elements)
  9. firstFunnyString(List words, String containedTest)