Home > Back-end >  [for] a List how to remove the different values of the same key?
[for] a List how to remove the different values of the same key?

Time:09-21


For example I want to pick up the key "DEPARTMENT_NAME" all the values, the boy all the values, how should respectively take? The final result is to use the map to return to the front desk,
This is the specific code

I want to save and use the map to loop back to just know the map in the same key value will overwrite the previous one, so finally got only a value
Because I want to do is to use echarts to show different college, the number of boys and girls, need three parameters: school, boys and girls, so I just need to get at the front desk sets, and a collection of both men and women of the college is ok, don't know how to take each of these three parameters values? For a great god

CodePudding user response:

Is too low or it's a difficult problem, ask the great spirit

CodePudding user response:

Not really no one

CodePudding user response:

Not very understand which is the data required to format, but would like to deposit your repeat key words can try MultiMap

CodePudding user response:

Has been solved, why I must to the map, three parameters are put forward in the for loop for three of the list is not finished, and then use stringbuilder joining together, and then use the map set a key parameters, put the builder to the value of the position, to return to the front desk,
Alas, it is a very simple question to want to so complicated, I don't know will meet what kind of problems in the later work

CodePudding user response:

Look at the steam related things

CodePudding user response:

A for loop not done?
Return to the map in college name as the key to (college school boys, the total number of girls) as the value is ok
 Map The map=new HashMap<> (a); 
For (Dto count: the count List) {
The map. The put (count. GetAsString (" DEPARTMENT_NAME "),
The String. Format (" % d, % s, % s ", count. GetAsInteger (" boys ") + count. GetAsInteger (" girls "), and count. GetAsInteger (" boys "), count. GetAsInteger (" girls ")));
}

CodePudding user response:

CountList. Stream (). The map (s - & gt; S.g et (" DEPARTMENT_NAME ");) Collect (Collectors. ToList ())

CodePudding user response:

reference 4 floor sheep to eat the rainbow response:
has been solved, why I must to the map, three parameters are put forward in the for loop for three of the list is not finished, and then use stringbuilder joining together, and then use the map set a key parameters, put the builder to the value of the position, to return to the front desk,
Alas, it is a very simple question to want to so complicated, I don't know will meet what kind of problems in the later work

Or trouble, echarts final acceptance is an array, so you direct countlist in json form to the front desk, use js traversal, more simple,

CodePudding user response:

If you feel trouble, you can consider to redefine the source data structure,

CodePudding user response:

The value of the map is Obj type, don't change the key, the value in the list can not?

CodePudding user response:

A well-fed feel good myself

CodePudding user response:

Can only use traversal

CodePudding user response:

refer to the eighth floor nayi_224 response:
Quote: refer to 4th floor sheep eat the rainbow response:

Has been solved, why I must to the map, three parameters are put forward in the for loop for three of the list is not finished, and then use stringbuilder joining together, and then use the map set a key parameters, put the builder to the value of the position, to return to the front desk,
Alas, it is a very simple question to want to so complicated, I don't know will meet what kind of problems in the later work

Or trouble, echarts final acceptance is an array, so you direct countlist in json form to the front desk, use js traversal, more simple,
to ask
  • Related