Java examples for Collection Framework:List
import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] arguments) { List<String> list = new ArrayList<>(); String[] codes = { "alpha", "lambda", "gamma", "delta", "zeta" }; for (int i = 0; i < codes.length; i++) { if (!list.contains(codes[i])) { list.add(codes[i]);//ww w . j a v a 2 s. c om } } // display all codes for (String code : list) { System.out.println(code); } } }