If the same key exists in this method, an error will be reported
Map<String,JKStackRedEx> result = v.stream().collect(Collectors.toMap(a->a.getManuId(),a->a));
The following method can be used to avoid error reporting. The parameter returned by return can specify which value to use to override value1 or Value2
Map<String,JKStackRedEx> result = v.stream().collect(Collectors.toMap(a->a.getManuId(),a->a, (value1, value2) -> {
return value2;
}));
You can also use multiple attributes to splice keys
Map<String,JKStackRedEx> result = v.stream().collect(Collectors.toMap(a->a.getManuId().concat(a.getStackingNum()),a->a, (value1, value2) -> {
return value2;
}));
Read More:
- Solution of duplicate entry ‘value’ for key ‘field name’ in MySQL
- The solution of duplicate entry ‘for key’ primary ‘when inserting data in MySQL
- How to Fix Warning: Statement lambda can be replaced with expression lambda
- Duplicate entry ‘787192513’ for key ‘primary’
- E11000 duplicate key error collection in mongodb
- mysql Error Code: 1022. Can’t write; duplicate key in table `xxx`
- Txt import MySQL: error 1062 (23000): duplicate entry ‘0’ for key ‘primary’
- Dbsql occurs when configuring SAP ATC during SCI check_DUPLICATE_KEY_ERROR
- pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: anjuke.ershoufang index
- Map to vector pair map.second sort
- Mongoose Error: e11000 duplicate key error collection, code: 11000
- Insert keyframe giving keying set failed to insert any key frames (solved)
- Insert keyframe giving keying set failed to insert any key frames
- [reprint and save] MySQL does not set the primary key and uses the self growing ID method
- [go] solve the fatal error of go: concurrent map writes map non concurrent security
- Error handling when ABP specifies map object during map operation
- The use of C + + template function and lambda expression
- Duplicate keys detected: ‘XXXX’. This may cause an update error. Solution
- Upgrade/reinstall win10 system–prompt the solution to fail to verify the key
- Disk error press any key to restart solution