Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**
     * Removes nulls from provided collection.
     * 
     * @param c
     *            to remove nulls from
     * @return number of removed elements
     */
    @SuppressWarnings("rawtypes")
    public static int removeNulls(Collection c) {
        int removed = 0;
        Iterator iterator = c.iterator();
        while (iterator.hasNext()) {
            if (iterator.next() == null) {
                iterator.remove();
                removed++;
            }
        }
        return removed;
    }
}