remove Duplication In Order in a List - Java java.util

Java examples for java.util:List Filter

Description

remove Duplication In Order in a List

Demo Code


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

import java.util.LinkedHashSet;
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(removeDuplicationInOrder(list));
    }//from w  w w . j  a va 2  s  .  c  om

    public static <T> List<T> removeDuplicationInOrder(List<T> list) {
        return new ArrayList<T>(new LinkedHashSet<T>(list));
    }
}

Related Tutorials