Create Java List with Initial Values

In this article, we’ll introduce various ways of creating List with initial values, at the time of its construction.

We’ll first introduce how to do it with Java built-in methods. Then we’ll also share how to do it with Google Guava.

How to Check if Two Lists are Equal

There are three cases when we are talking about this topic.

Case 1: two lists are strictly equal, they have the same size, the elements in the lists have same order, and all corresponding pairs of elements in the two lists are equal;

Case 2: two lists containing the same elements, they have the same size, and there are duplicate elements within the lists. However, the number of counts each element appears in the two lists must be the same.

Case 3: two lists containing the same elements, regardless of element orders or whether the elements have the same duplication counts.

Java Stream.flatMap Method

Java 8 Stream.flatMap() method is used to flatten stream of collections to a stream of objects. In short, we can say that it allows us to combine the objects from multiple collections into a single collection.

Difference Between Two Lists

In this article, we’ll introduce the method to find the differences between two lists in Java. There are a few different approaches, let’s go through them one by one.