greyhat49

HashMap ArrayList<Double[]>

Oct 25th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. public static void main(String[] args) {        
  2.         Hashtable ht = new Hashtable();
  3.  
  4.         //you add elements to Hashtable using put method
  5.         //put(key, value)
  6.         ht.put("Java", new Double[]{1.2, 2.4, 3.3});
  7.         ht.put(".NET", new Double[]{1.2, 2.5, 5.6});
  8.         ht.put("Javascript", new Double[]{1.2, 2.4, 3.1});
  9.         ht.put("HTML", new Double[]{1.2, 2.4, 7.6});
  10.        
  11.         //looping through all the elements in hashtable
  12. //        String str;
  13. //        //you can retrieve all the keys in hashtable using .keys() method
  14. //        Enumeration names = ht.keys();
  15. //        while (names.hasMoreElements()) {
  16. //            //next element retrieves the next element in the dictionary
  17. //            str = (String) names.nextElement();
  18. //            //.get(key) returns the value of the key stored in the hashtable
  19. //            System.out.println(str + ": " + ht.get(str) + newLine);
  20. //        }
  21.        
  22.         Set<String> keys = ht.keySet();
  23.         for(String key: keys){
  24.             System.out.println("key: "+key+"\nvalue: "+ht.get(key));
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment