Java examples for Collection Framework:List
Method will determine if all elements in the input ArrayList are all unique
//package com.java2s; import java.util.ArrayList; public class Main { /**/*from w ww. j av a 2s.c o m*/ * Method will determine if all elements in the input set are all unique * * @param arraySet - the input array to check * @return true if there are no duplicates, false if duplicates exists */ public static boolean isUnique(ArrayList<Integer> arraySet) { boolean isUnique = true; if (arraySet == null) { isUnique = false; } else { for (int i = 0; i < arraySet.size() && isUnique; i++) { for (int j = i + 1; j < arraySet.size() && isUnique; j++) { isUnique = arraySet.get(i) != arraySet.get(j); } } } return isUnique; } }