Menu
Question Index
...


Write a program to identify those keys whose value has a special characters in the given hash map. Assume special characters are those which are not alphabets or numbers.

Input (Hash Map) Output (String List)
{key4=>"how", key3=>null, key7=>null, key5=>"?", key6=>"Hai", key2=>"4+5", key1=>null, key8=>"4*6"} [key5, key2, key8]
{key4=>"`", key3=>"value1", key6=>null, key2=>"a==b?", key1=>"A*(D+C)", key8=>null, key7=>"!", key9=>"are"} [key4, key2, key1, key7]
{key4=>"how", key3=>"'", key6=>"nul", key2=>"Hello", key1=>"~", key8=>"you", key7=>"nu1l", key9=>"int c= a+b;"} [key3, key9, Key1]
{key10=>"A/B", key3=>null, key6=>"8^2", key2=>"ull", key1=>"test", key8=>"you", key7=>null, key9=>"9<8"} [key10, key6, Key9]

class GetKeysWithSpecialCharacterValues

{    public static void main(String s[])
    {
        Map inputMap = new HashMap();
        inputMap.put("key1", "Hai");
        inputMap.put("key2", "7%6$");
        inputMap.put("key3", null);
        inputMap.put("key4", "how");
        inputMap.put("key6", null);
        inputMap.put("key7", "75%");
        inputMap.put("key8", "you");
        inputMap.put("key9", "234");
        inputMap.put("key9", ".");
        System.out.println("The keys are : " + getKeysListWhoseValueIsNull(inputMap));

    }


public static List<String> getKeysListWhoseValueIsNull(Map<String, String> inputMap) {
//Write code here identify those keys whose value has special characters
}
}

Doubts

Problems

Topic: Advanced Java Programming Concepts

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App