Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static boolean containsLike(Class[] array, Class value) {
        return null != array && indexOfLike(array, value) >= 0;
    }

    @SuppressWarnings("unchecked")
    public static int indexOfLike(Class[] a, Class key) {
        if (null == a || a.length == 0 || null == key) {
            return -1;
        }
        for (int i = 0; i < a.length; i++) {
            final Class item = a[i];
            // is 'item' equal or super-class of 'key'?
            if (key.equals(item) || item.isAssignableFrom(key)) {
                return i;
            }
        }
        return -1;
    }
}