Home > Back-end >  A list with multiple Map, how to get the first Map corresponding to the Key and the Value
A list with multiple Map, how to get the first Map corresponding to the Key and the Value

Time:09-23

List CategoryEventFeature=(List & gt;) The features. GetOrDefault (" event_category ", new ArrayList ());


CategoryEventFeature has five values, how to get the first map

CodePudding user response:

List list=new ArrayList<> (a);
List. The get (0);
HashMap The map=new HashMap<> (a);
Set KeySet=map. The keySet ();
Iterator The iterator=keySet iterator ();
For (iterator. HasNext ()) {
String key=iterator. Next ();
The String value=https://bbs.csdn.net/topics/map.get (key);
}

CodePudding user response:

 Map M=categoryEventFeature. Get (0);//get the first Map, subscript, because is the ArrayList (0 is the first 
For (Map. Entry e: m.e ntrySet ()) {//traverse Map
System. The out. Printf (" key=% s, value=https://bbs.csdn.net/topics/%s/n ", um participant etKey (), um participant etValue ());
}

CodePudding user response:

Give you one of the most simple way ((HashMap) categoryEventFeature. Get (0). The get (" key "))

CodePudding user response:

Give you one of the most simple way ((HashMap) categoryEventFeature. Get (0). The get (" key "))

CodePudding user response:

Give you one of the most simple way ((HashMap) categoryEventFeature. Get (0). The get (" key "))

CodePudding user response:

Arrays. ToString (map. Get (key))
  • Related