java dictionary
Map<String, String> dictionary = new HashMap<String, String>();
dictionary.put("key", "value");
String value = dictionary.get("key");
java dictionary
Map<String, String> dictionary = new HashMap<String, String>();
dictionary.put("key", "value");
String value = dictionary.get("key");
built dictionary in java
import java.util.*;
class My_Dictionary
{
public static void main(String[] args)
{
// creating a My HashTable Dictionary
Hashtable<String, String> my_dict = new Hashtable<String, String>();
// Using a few dictionary Class methods
// using put method
my_dict.put("01", "Apple");
my_dict.put("10", "Banana");
// using get() method
System.out.println("\nValue at key = 10 : " + my_dict.get("10"));
System.out.println("Value at key = 11 : " + my_dict.get("11"));
// using isEmpty() method
System.out.println("\nIs my dictionary empty? : " + my_dict.isEmpty() + "\n");
// using remove() method
// remove value at key 10
my_dict.remove("10");
System.out.println("Checking if the removed value exists: " + my_dict.get("10"));
System.out.println("\nSize of my_dict : " + my_dict.size());
}
}
dictionary in java
Map<String, String> map = new HashMap<String, String>();
map.put("dog", "type of animal");
System.out.println(map.get("dog"));
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us