diff --git a/java-collections/README.md b/java-collections/README.md
new file mode 100644
index 0000000000..480b7f257a
--- /dev/null
+++ b/java-collections/README.md
@@ -0,0 +1,8 @@
+## Java Collections Examples
+
+This module support code for articles about handling java collections and arrays.
+
+### Relevant Articles:
+- [Comparing two integer arrays in Java](https://stackoverflow.com/questions/14897366/comparing-two-integer-arrays-in-java)
+- [Compare two arrays with not the same order](https://stackoverflow.com/questions/54711228/compare-two-arrays-with-not-the-same-order)
+- More articles: [[next -->]](../java-collections-conversions-2)
\ No newline at end of file
diff --git a/java-collections/pom.xml b/java-collections/pom.xml
new file mode 100644
index 0000000000..5e0ee42244
--- /dev/null
+++ b/java-collections/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+ java-collections
+ 0.1.0-SNAPSHOT
+ java-collections
+ jar
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../parent-java
+
+
+
+
+ org.apache.commons
+ commons-collections4
+ ${commons-collections4.version}
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+ org.hamcrest
+ hamcrest-all
+ ${hamcrest-all.version}
+ test
+
+
+
+
+ java-collections
+
+
+ src/main/resources
+ true
+
+
+
+
+
+ 4.1
+
+
diff --git a/java-collections/src/main/java/com/baeldung/comparingarrays/Plane.java b/java-collections/src/main/java/com/baeldung/comparingarrays/Plane.java
new file mode 100644
index 0000000000..db61807878
--- /dev/null
+++ b/java-collections/src/main/java/com/baeldung/comparingarrays/Plane.java
@@ -0,0 +1,39 @@
+package com.baeldung.comparingarrays;
+
+import java.util.Objects;
+
+public class Plane {
+
+ private final String name;
+
+ private final String model;
+
+ public Plane(String name, String model) {
+
+ this.name = name;
+ this.model = model;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ Plane plane = (Plane) o;
+ return Objects.equals(name, plane.name) && Objects.equals(model, plane.model);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, model);
+ }
+}
diff --git a/java-collections/src/main/resources/logback.xml b/java-collections/src/main/resources/logback.xml
new file mode 100644
index 0000000000..7d900d8ea8
--- /dev/null
+++ b/java-collections/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java-collections/src/test/java/com/baeldung/DeepEqualsCompareUnitTest.java b/java-collections/src/test/java/com/baeldung/DeepEqualsCompareUnitTest.java
new file mode 100644
index 0000000000..f311d0e5c9
--- /dev/null
+++ b/java-collections/src/test/java/com/baeldung/DeepEqualsCompareUnitTest.java
@@ -0,0 +1,34 @@
+package com.baeldung;
+
+import com.baeldung.comparingarrays.Plane;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DeepEqualsCompareUnitTest {
+
+ @Test
+ public void givenArray1andArray2_whenSameContent_thenDeepEquals() {
+ final Plane[][] planes1 = new Plane[][] { new Plane[] { new Plane("Plane 1", "A320") },
+ new Plane[] { new Plane("Plane 2", "B738") } };
+ final Plane[][] planes2 = new Plane[][] { new Plane[] { new Plane("Plane 1", "A320") },
+ new Plane[] { new Plane("Plane 2", "B738") } };
+
+ boolean result = Arrays.deepEquals(planes1, planes2);
+ assertTrue("Result is not true", result);
+ }
+
+ @Test
+ public void givenArray1andArray2_whenNotSameContent_thenNotDeepEquals() {
+ final Plane[][] planes1 = new Plane[][] { new Plane[] { new Plane("Plane 1", "A320") },
+ new Plane[] { new Plane("Plane 2", "B738") } };
+ final Plane[][] planes2 = new Plane[][] { new Plane[] { new Plane("Plane 2", "B738") },
+ new Plane[] { new Plane("Plane 1", "A320") } };
+
+ boolean result = Arrays.deepEquals(planes1, planes2);
+ assertFalse("Result is true", result);
+ }
+}
diff --git a/java-collections/src/test/java/com/baeldung/EqualsCompareUnitTest.java b/java-collections/src/test/java/com/baeldung/EqualsCompareUnitTest.java
new file mode 100644
index 0000000000..b56395a848
--- /dev/null
+++ b/java-collections/src/test/java/com/baeldung/EqualsCompareUnitTest.java
@@ -0,0 +1,29 @@
+package com.baeldung;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class EqualsCompareUnitTest {
+
+ @Test
+ public void givenArray1andArray2_whenSameContent_thenEquals() {
+ final String[] planes1 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+ final String[] planes2 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+
+ boolean result = Arrays.equals(planes1, planes2);
+ assertTrue("Result is not true", result);
+ }
+
+ @Test
+ public void givenArray1andArray2_whenSameContentOtherSort_thenNotEquals() {
+ final String[] planes1 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+ final String[] planes2 = new String[] { "B738", "A320", "A321", "A319", "B77W", "B737", "A333", "A332" };
+
+ boolean result = Arrays.equals(planes1, planes2);
+ assertFalse("Result is true", result);
+ }
+}
diff --git a/java-collections/src/test/java/com/baeldung/LengthsCompareUnitTest.java b/java-collections/src/test/java/com/baeldung/LengthsCompareUnitTest.java
new file mode 100644
index 0000000000..8b3c90c427
--- /dev/null
+++ b/java-collections/src/test/java/com/baeldung/LengthsCompareUnitTest.java
@@ -0,0 +1,22 @@
+package com.baeldung;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.collection.IsArrayWithSize.arrayWithSize;
+import static org.junit.Assert.assertThat;
+
+public class LengthsCompareUnitTest {
+
+ @Test
+ public void givenArray1andArray2_whenSameSizes_thenSizeEqualsOk() {
+ final String[] planes1 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+ final Integer[] quantities = new Integer[] { 10, 12, 34, 45, 12, 43, 5, 2 };
+
+ assertThat(planes1, arrayWithSize(8));
+ assertThat(quantities, arrayWithSize(8));
+ assertThat(planes1.length, is(8));
+ assertThat(quantities.length, is(8));
+ }
+}
+
diff --git a/java-collections/src/test/java/com/baeldung/OrderCompareUnitTest.java b/java-collections/src/test/java/com/baeldung/OrderCompareUnitTest.java
new file mode 100644
index 0000000000..8be7251c05
--- /dev/null
+++ b/java-collections/src/test/java/com/baeldung/OrderCompareUnitTest.java
@@ -0,0 +1,34 @@
+package com.baeldung;
+
+import com.baeldung.comparingarrays.Plane;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+import static org.junit.Assert.assertTrue;
+
+public class OrderCompareUnitTest {
+ @Test
+ public void givenArray1andArray2_whenNotSameContent_thenNotDeepEquals() {
+ final Plane[][] planes1 = new Plane[][] {
+ new Plane[] { new Plane("Plane 1", "A320"), new Plane("Plane 2", "B738") } };
+ final Plane[][] planes2 = new Plane[][] {
+ new Plane[] { new Plane("Plane 2", "B738"), new Plane("Plane 1", "A320") } };
+
+ Comparator planeComparator = (o1, o2) -> {
+ if (o1.getName()
+ .equals(o2.getName())) {
+ return o2.getModel()
+ .compareTo(o1.getModel());
+ }
+ return o2.getName()
+ .compareTo(o1.getName());
+ };
+ Arrays.sort(planes1[0], planeComparator);
+ Arrays.sort(planes2[0], planeComparator);
+
+ boolean result = Arrays.deepEquals(planes1, planes2);
+ assertTrue("Result is false", result);
+ }
+}
diff --git a/java-collections/src/test/java/com/baeldung/ReferenceCompareUnitTest.java b/java-collections/src/test/java/com/baeldung/ReferenceCompareUnitTest.java
new file mode 100644
index 0000000000..9716a34607
--- /dev/null
+++ b/java-collections/src/test/java/com/baeldung/ReferenceCompareUnitTest.java
@@ -0,0 +1,34 @@
+package com.baeldung;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+
+public class ReferenceCompareUnitTest {
+
+ @Test
+ public void givenArray1andArray2_whenEquals_thenEqual() {
+ final String[] planes1 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+ final String[] planes2 = planes1;
+
+ assertSame("Objects are not equal!", planes1, planes2);
+
+ planes2[0] = "747";
+
+ assertSame("Objects are not same!", planes1, planes2);
+ assertEquals("Objects are not equal!", "747", planes2[0]);
+ assertEquals("Objects are not equal!", "747", planes1[0]);
+ }
+
+ @Test
+ public void givenArray1andArray2_whenDifferentValues_thenNotEqual() {
+ final String[] planes1 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+ final String[] planes2 = new String[] { "A320", "B738", "A321", "A319", "B77W", "B737", "A333", "A332" };
+
+ assertNotSame("Objects are the same!", planes1, planes2);
+ assertNotEquals("Objects are equal!", planes1, planes2);
+ }
+}