Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static <T> Set removeRepetition(Collection<T> ts) {
        if (ts == null || ts.isEmpty()) {
            return Collections.emptySet();
        }
        Map<T, Object> map = new LinkedHashMap();
        for (T t : ts) {
            if (!map.containsKey(t)) {
                map.put(t, -1);
            }
        }
        Set<T> set = map.keySet();
        return set;
    }
}