Comparing the content of Lists against some condition is a common use case to handle in many business scenarios. This comparison can be broadly classified as:
- Comparing each element of a List against some condition. As an example, you have a List of Employee Objects and you need to check that all your Employees are above 18.
- One or more elements from one List match(es) the elements of another List.
- All elements of a List exist in another List.
Now, developing these use cases is very easy in Java 7 with relatively few lines of code. The following is an example where we are comparing two Lists in Java 7 and checking if any element from List 1 exists in List 2.
from DZone.com Feed https://ift.tt/2kFn3AQ
No comments:
Post a Comment