[英]Validate two lists together using Stream
Wish to compare, two (object) lists for希望比较,两个(对象)列表
Possible?可能的?
String A = "one,two,three|four,five,six|seven,eight,nine"
String B = "three,six,nine"
List L1 = List.of(A.split("\\|"));
List L2 = List.of(B.split(","));
Give object of List L1, if the third sub value of an element matches with element of the List L2.如果元素的第三个子值与列表 L2 的元素匹配,则给出列表 L1 的对象。
Note: This answered the question when it was:注意:这回答了以下问题:
Wish to compare, two (object) lists for希望比较,两个(对象)列表
1. Not null1.不为空
2. Not empty2. 不为空
3. Equal Size3. 大小相等
4. Nth Element Field values are same4.第N个元素字段值相同
Possible?可能的?
Since then, it was significantly changed...从那时起,它发生了重大变化......
Seems like you can go with Objects.equals(list1, list2);
似乎您可以使用
Objects.equals(list1, list2);
2./3. 2./3。 When the sizes are different, it will return false.
当大小不同时,它将返回false。
In any other case, it will return true.在任何其他情况下,它将返回 true。
Disclaimer: This works for the standard Lists in the Collections Framework.免责声明:这适用于集合框架中的标准列表。 There might be other implementations which implement
equals()
differently (and therefore behave differently when applied to Objects.equals()
).可能还有其他实现方式以不同方式实现
equals()
(因此在应用于Objects.equals()
时表现不同)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.