import java.util.
HashMap;
public class Dictionary {
public static void main(String[] args) {
// Create a HashMap where the key is the word and the value is its
definition
HashMap<String, String> dictionary = new HashMap<>();
// Add entries (word, definition)
dictionary.put("Apple", "A round fruit with red, green, or yellow skin and
a whitish interior.");
dictionary.put("Banana", "A long, curved fruit with a yellow skin and soft,
sweet, white flesh inside.");
dictionary.put("Java", "A high-level, class-based, object-oriented
programming language.");
dictionary.put("HashMap", "A map implementation that stores key-value pairs
using hashing.");
// Retrieve a definition based on a word
System.out.println("Definition of Apple: " + dictionary.get("Apple"));
System.out.println("Definition of Java: " + dictionary.get("Java"));
// Check if a word exists in the dictionary
String wordToFind = "Python";
if (dictionary.containsKey(wordToFind)) {
System.out.println("Definition of " + wordToFind + ": " +
dictionary.get(wordToFind));
} else {
System.out.println(wordToFind + " is not found in the dictionary.");
}
// Print all words and their definitions in the dictionary
System.out.println("\nComplete Dictionary:");
for (String word : dictionary.keySet()) {
System.out.println(word + ": " + dictionary.get(word));
}
// Removing an entry from the dictionary
dictionary.remove("Banana");
System.out.println("\nAfter removing Banana:");
for (String word : dictionary.keySet()) {
System.out.println(word + ": " + dictionary.get(word));
}
}
}