How do I check if a Key is mapped in a HashMap?
Here is my code:
currencyMap = new HashMap<String, String>(); currencyMap.put("USD", "US Dollar"); currencyMap.put("EUR", "Euro"); currencyMap.put("GBP", "British Pound Sterling"); currencyMap.put("JPY", "Japanese Yen"); currencyMap.put("CAD", "Canadian Dollar"); currencyMap.put("AUD", "Australian Dollar"); String checkCurrency = "CHF"; // Swiss Franc // List Keys for (String key : currencyMap.keySet() ) { String value = currencyMap.get( key ); System.out.println( key + " = " + value); }