1、对map按值过滤返回值
1 public class TestMapFilter { 2 3 public static void main(String[] args) { 4 Map<Integer, String> HOSTING = new HashMap<>(); 5 HOSTING.put(1, "linode.com"); 6 HOSTING.put(2, "heroku.com"); 7 HOSTING.put(3, "digitalocean.com"); 8 HOSTING.put(4, "aws.amazon.com"); 9 10 // Before Java 8 11 String result = ""; 12 for (Map.Entry<Integer, String> entry : HOSTING.entrySet()) { 13 if ("heroku.com".equals(entry.getValue())) { 14 result = entry.getValue(); 15 } 16 } 17 System.out.println("Before Java 8: " +