remove Duplication in a List - Java java.util

Java examples for java.util:List Filter

Description

remove Duplication in a List

Demo Code


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

import java.util.HashSet;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List list = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(removeDuplication(list));
    }/*from w  ww  . ja va 2  s .  c o m*/

    public static <T> List<T> removeDuplication(List<T> list) {
        return new ArrayList<T>(new HashSet<T>(list));
    }
}

Related Tutorials