Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
    /**
     * Convert to Set - this operation removes the duplicates in original list.
     * @param list
     * @return
     */
    public static <T> Set<T> converToSet(List<T> list) {
        if (list == null || list.isEmpty()) {
            return Collections.emptySet();
        }
        return new HashSet<T>(list);
    }
}