Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.util.ArrayList;

import java.util.HashSet;
import java.util.Iterator;

import java.util.List;

import java.util.Set;

public class Main {
    public static <T> List<T> copyWithoutDublicates(List<T> l) {
        final List<T> result = new ArrayList<T>();
        final Set<T> set = new HashSet<T>();
        for (Iterator<T> it = l.iterator(); it.hasNext();) {
            final T t = it.next();
            if (set.add(t)) {
                result.add(t);
            }
        }
        return result;
    }
}