As the title says, I have a question. I have 2 arrays. One length is five. The other one is seven in length.
Even if the objects in the two arrays are different, if the objects in the array have the same id, it will be judged to have the same object.
There are a lot of answers about javascript, but it seems like there aren't many answers about java. Anyone who has had the same problem can share the solution. If you have any similar questions to my question, please share. Thank you so much.
Below are my attempts and my sample data.
"maxCastings"
[
{
"characterNo": "100121",
"characterName": "막심 드 윈터",
"manNo": "",
"manName": "",
},
{
"characterNo": "100122",
"characterName": "댄버스 부인",
"manNo": "3727",
"manName": "옥주현",
},
{
"characterNo": "100123",
"characterName": "나",
"manNo": "29655",
"manName": "이지혜",
},
{
"characterNo": "100124",
"characterName": "잭 파벨",
"manNo": "4202",
"manName": "이창용",
},
{
"characterNo": "100125",
"characterName": "반 호퍼 부인",
"manNo": "40282",
"manName": "한유란",
},
{
"characterNo": "100126",
"characterName": "베아트리체",
"manNo": "3543",
"manName": "류수화",
},
{
"characterNo": "100128",
"characterName": "프랭크 크롤리",
"manNo": "42618",
"manName": "임정모",
},
{
"characterNo": "100130",
"characterName": "줄리앙 대령",
"manNo": "31476",
"manName": "김현웅",
}
]
and 5 objects of list is this.
"castings"
[
{
"characterNo": "100121",
"characterName": "막심 드 윈터",
"manName": "에녹"
},
{
"characterNo": "100122",
"characterName": "댄버스 부인",
"manName": "옥주현"
},
{
"characterNo": "100123",
"characterName": "나",
"manName": "임혜영"
},
{
"characterNo": "100124",
"characterName": "잭 파벨",
"manName": "최민철"
},
{
"characterNo": "100125",
"characterName": "반 호퍼 부인",
"manName": "김지선"
},
{
"characterNo": "100126",
"characterName": "베아트리체",
"manName": "김경호"
}
]
If the manName is different but characterNo is the same, I want to check that both arrays have the same element.
What I want is 2 out of 7 not the same element.
here is my code
List<Casting> unMatchList = maxCastings.stream().filter(o1 -> castings.stream().noneMatch(o2 -> o2.getCharacterNo().equals(o1.getCharacterNo()))).collect(
Collectors.toList());
and this returns
Error:(737, 95) java: local variables referenced from a lambda expression must be final or effectively final