Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java find duplicate element in list

	public static Set<String> findDuplicates(List<String> listContainingDuplicates) {
 
		final Set<String> setToReturn = new HashSet<String>();
		final Set<String> set1 = new HashSet<String>();
 
		for (String yourInt : listContainingDuplicates) {
			if (!set1.add(yourInt)) {
				setToReturn.add(yourInt);
			}
		}
		return setToReturn;
	}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #find #duplicate #element #list
ADD COMMENT
Topic
Name
5+8 =