Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    @SuppressWarnings("unchecked")
    public static <O> List<O> convert(List<?> list, Class<O> clazz) {
        if (list == null) {
            return null;
        }

        List<O> converted = new ArrayList<O>();

        for (Object item : list) {
            if (clazz.isInstance(item)) {
                converted.add((O) item);
            }
        }

        return converted;
    }
}