diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java index abf275865d..c57c1f96b8 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/listandset/ListAndSetUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.listandset; import org.junit.Test; +import org.junit.Assert; import java.util.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -37,15 +38,6 @@ public class ListAndSetUnitTest { set2.add(2); set2.add(3); set2.add(4); - boolean ordered = true; - Object[] arr1 = set1.toArray(); - Object[] arr2 = set2.toArray(); - for(int i=0; i < arr1.length; i++){ - if (!arr1[i].equals(arr2[i])) { - ordered = false; - break; - } - } - assertTrue(ordered); + Assert.assertArrayEquals(set1.toArray(), set2.toArray()); } -} \ No newline at end of file +}