Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.List;

public class Main {
    /**
     * Returns whether all members of the list are either null or of the specific type
     */
    public static boolean contains(List<?> list, Class<?> type) {
        for (Object member : list) {
            if (member != null && !(type.isInstance(member))) {
                return false;
            }
        }
        return true;
    }
}