Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    public static void checkNoNullElements(Collection<?> collection, String name) {
        if (collection == null)
            throw new NullPointerException(name);

        int index = 0;
        for (Object element : collection) {
            if (element == null)
                throw new NullPointerException(name + "[" + index + "]");
            index++;
        }
    }
}