Static Boolean Q1 HashMap inputMap TODO Return trie if input

Static Boolean Q_1 (HashMap inputMap) {//TODO: Return trie if inputMap has more than 2 key - value pairs, false otherwise return true;} static HashMap Q_2(string key, int value) {//TODD: Return a new HashMap containing the input value at the input key as its only key-value pair return null;}| public static void main(String [] args) {}}

Solution

HashMapTester.java

import java.util.HashMap;


public class HashMapTester {

   static boolean Q1(HashMap<Character, Integer> inputMap){
       if(inputMap.size() > 2){
           return true;
       }
       else{
           return false;
       }

   }
   static HashMap<String, Integer> Q2(String key, int value) {
       HashMap<String, Integer> map = new HashMap<String, Integer>();
       map.put(key, value);
       return map;

   }
   public static void main(String[] args) {
       HashMap<Character, Integer> inputMap = new HashMap<Character, Integer>();
       inputMap.put(\'A\', 1);
       inputMap.put(\'B\', 2);
       inputMap.put(\'C\', 3);
       System.out.println(Q1(inputMap));
       System.out.println(Q2(\"Test\", 111));
      
   }

}

Output:

true
{Test=111}

 Static Boolean Q_1 (HashMap inputMap) {//TODO: Return trie if inputMap has more than 2 key - value pairs, false otherwise return true;} static HashMap Q_2(stri

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site