treemap containsvalue 28 29 method in java

Solutions on MaxInterview for treemap containsvalue 28 29 method in java by the best coders in the world

showing results for - "treemap containsvalue 28 29 method in java"
Hugo
28 Mar 2017
1import java.util.TreeMap;
2public class TreeMapContainsValueMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
7      // Map string values to integer keys
8      tm.put(16, "indigo");
9      tm.put(12, "red");
10      tm.put(14, "indigo");
11      tm.put(18, "orange");
12      tm.put(20, "violet");
13      System.out.println("TreeMap before using containsValue() method: " + tm);
14      // checking for Value 'indigo'
15      System.out.println("Does value 'indigo' present? " + tm.containsValue("indigo"));
16      // checking for Value 'blue'
17      System.out.println("Does value 'blue' present? " + tm.containsValue("blue"));
18   }
19}
María Fernanda
26 Jan 2020
1map Integer values to String keys
2import java.util.TreeMap;
3public class TreeMapContainsValueMethodExample
4{
5   public static void main(String[] args)
6   {
7      TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
8      // Map integer values to string keys
9      tm.put("indigo", 16);
10      tm.put("red", 12);
11      tm.put("indigo", 14);
12      tm.put("orange", 18);
13      tm.put("violet", 20);
14      System.out.println("TreeMap before using containsValue() method: " + tm);
15      // Checking for the Value '12'
16      System.out.println("Does value '12' present? " + tm.containsValue(12));
17      // Checking for the Value '14'
18      System.out.println("Does value '14' present? " + tm.containsValue(14));
19      // Checking for the Value '20'
20      System.out.println("Does value '20' present? " + tm.containsValue(20));
21   }
22}