Java examples for Collection Framework:List
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static void main(String[] arguments) { List<String> list; String[] codes = { "alpha", "lambda", "gamma", "delta", "zeta" }; list = new ArrayList<>(); for (int i = 0; i < codes.length; i++) { if (!list.contains(codes[i])) { list.add(codes[i]);//from w w w . ja v a 2 s . co m } } for (Iterator<String> ite = list.iterator(); ite.hasNext();) { String output = (String) ite.next(); System.out.println(output); } } }