Java examples for java.util:List Element
Get unique elements from List
//package com.java2s; import java.util.ArrayList; 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(uiqList(list)); }//from w w w. j a v a2s. co m public static <T> List<T> uiqList(List<T> list) { if (list == null) { return list; } List<T> tList = new ArrayList<T>(list.size()); for (T t : list) { if (!tList.contains(t)) { tList.add(t); } } return tList; } }