Menu
Question Index
...

Write a program to get the sum of keys of given input by using one of the Map interface methods.

Input (Map) Output (Integer)
{1=A, 2=B, 3=C, 4=D, 5=E, 6=F} 21
{-4=Red, 12=Blue, -25=Yellow, -26=-Green} -43
{12=Lion, 60=Tiger, 5=Mouse, 9=Tiger, 0=Rabbit} 86
null null


import java.util.*;
class SumOfKeys
{
    public static void main(String s[])
    {
        Map<Integer, String> input = new WeakHashMap<Integer, String>();
        input.put(1, "A");
        input.put(2, "B");
        input.put(3, "C");
        input.put(4, "D");
        input.put(5, "E");
        input.put(6, "F");
        System.out.println("The sum of Keys is : " + sumOfKeys(input));

    }


    public static Integer sumOfKeys(Map<Integer, String> input) {
    }

}

Doubts

Problems

Topic: Java WeakHashMap Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App