Menu
Question Index
...

Write a program to get the values as an array from given input by using one of the Map interface methods.

Input (Map) Output (in[])
{A=1, B=2, C=3, D=4, E=5} {1, 2, 3, 4, 5}
{Red=-12, Yellow=22, Blue=55, White=33, Green=44} {-12, 22, 55, 33, 44}
{Book=-1, Pen=2, Pencil=-3, Scale=4} {-1, 2, -3, 4}
null null


import java.util.*;
class ValuesAsArray
{
    public static void main(String s[])
    {
        Map<String, Integer> input = new LinkedHashMap<String, Integer>();
        input.put("A", 1);
        input.put("E", 5);
        input.put("B", 2);
        input.put("C", 3);
        input.put("D", 4);
        input.put("A", 6);
        System.out.println("The values are :");
        for (int value : getValuesAsArray(input)) {
        System.out.println(value);
        }

    }


    public static int[] getValuesAsArray(Map<String, Integer> input) {
    }

}

Doubts

Problems

Topic: LinkedHashMap In Java with Code Example

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App