Advertisement
Guest User

Untitled

a guest
Jul 13th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Dictionary;
  2. import java.util.Enumeration;
  3.  
  4. public class DictonaryTest
  5. {
  6. public static void main(String[] args)
  7. {
  8. Dictionary d;
  9. d.put(new Integer(1),new Integer(100));
  10. d.put(new Integer(2),new Integer(200));
  11. d.put(new Integer(3),new Integer(300));
  12. d.put(new Integer(4),new Integer(400));
  13. d.put(new Integer(5),new Integer(500));
  14.  
  15. System.out.println("Size of dictionary : " + d.size());
  16. Enumeration ekey = d.keys();
  17. Enumeration eelement = d.elements();
  18.  
  19. System.out.println("Keys in the Dictionary...");
  20. while(ekey.hasMoreElements()){
  21. System.out.println(ekey.nextElement() + "t");
  22. }
  23.  
  24. System.out.println("Elements in the Dictionary...");
  25. while(eelement.hasMoreElements()){
  26. System.out.println(eelement.nextElement() + "t");
  27. }
  28.  
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement