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 {
    /**
     * Modifies and returns the collection.
     */
    public static Collection filterByClass(Collection collection, Class c) {
        for (Iterator i = collection.iterator(); i.hasNext();) {
            Object item = i.next();
            if (!c.isInstance(item)) {
                i.remove();
            }
        }

        return collection;
    }
}