Java examples for java.util:Collection Compare
compare Two Collections Equality
//package com.java2s; import java.util.Collection; public class Main { public static void main(String[] argv) { Collection expectedAffectedFiles = java.util.Arrays.asList("asdf", "java2s.com"); Collection affectedFiles = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(compareTwoCollectionsEquality( expectedAffectedFiles, affectedFiles)); }/*from w w w .jav a2 s . c om*/ /** * * @param expectedAffectedFiles * @param affectedFiles * @return */ public static boolean compareTwoCollectionsEquality( Collection<String> expectedAffectedFiles, Collection<String> affectedFiles) { int counter = 0; for (String f1 : affectedFiles) { for (String f2 : expectedAffectedFiles) { if (f1.equals(f2)) { counter++; } } } return expectedAffectedFiles.size() == counter; } }