Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the quickest way to get the submap of a map

Tags:

java

I have a map, I am wondering if there is a way to get some submap according to some condition. Any useful library?

like image 607
user705414 Avatar asked Dec 14 '11 07:12

user705414


People also ask

How do you get all the keys on a map?

To retrieve the set of keys from HashMap, use the keyset() method. However, for set of values, use the values() method.

How do I print just the value of maps?

Method 1: Print Map in Java Using for-each Loop Within the for-each loop, you can use Map's getValue() and getKey() methods to iterate over key-value pairs. This is the most systematic way to print a map and should be used if it is required to print both map keys and values.

How do you create a Submap?

Create a submap by using the Graphical Data Mapping editor. Create a submap by defining a Submap transform between an input object and an output object in a message map. Use the Graphical Data Mapping editor to convert a local map into a submap by using the Refactor to submap function.


1 Answers

In Guava the Maps class contains three different filtering methods, depending on whether you want to filter by key, value, or both.

like image 83
Jon Skeet Avatar answered Oct 25 '22 02:10

Jon Skeet