Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class HashTable1 here.
- *
- * Samuel Berkat Hulu
- * @version 5.0 Tugas Struktur Data
- */
- import java.util.Hashtable;
- import java.util.Iterator;
- public class HashTable1
- {
- public static void main(String[] args)
- {
- //Buat Hastale
- Hashtable<Integer, String> hashtable = new Hashtable<>();
- hashtable.put(1, "X");
- hashtable.put(2, "Y");
- hashtable.put(3, "Z");
- System.out.println(hashtable);
- String value = hashtable.get(1);
- System.out.println(value);
- hashtable.remove(3);
- Iterator<Integer> itr = hashtable.keySet().iterator();
- while(itr.hasNext())
- {
- Integer key = itr.next();
- String mappedValue = hashtable.get(key);
- System.out.println("Kunci : " + key + ", Nilai : " + mappedValue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement