List of usage examples for java.util HashMap put
public V put(K key, V value)
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hashmap = new HashMap<String, String>(); hashmap.put("one", "1"); hashmap.put("two", "2"); hashmap.put("three", "3"); hashmap.put("four", "4"); hashmap.put("five", "5"); hashmap.put("six", "6"); Iterator<String> keyIterator = hashmap.keySet().iterator(); Iterator<String> valueIterator = hashmap.values().iterator(); while (keyIterator.hasNext()) { System.out.println("key: " + keyIterator.next()); }/*from ww w . j av a 2s . c o m*/ while (valueIterator.hasNext()) { System.out.println("value: " + valueIterator.next()); } }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "REPLACED !!"); ht.put("4", "Four"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); }/* w w w. j a v a2 s .c o m*/ ht.putAll(hMap); e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, String> newmap = new HashMap<Integer, String>(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "from"); newmap.put(3, "java2s.com"); System.out.println("Size of the map: " + newmap.size()); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { PdfReader reader = new PdfReader("test.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my.pdf")); stamper.insertPage(1, PageSize.A4);/*from w w w . ja va 2 s . co m*/ PdfContentByte cb = stamper.getOverContent(1); PdfImportedPage p = stamper.getImportedPage(reader, 2); cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 450); p = stamper.getImportedPage(reader, 3); cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 300f, 450); p = stamper.getImportedPage(reader, 4); cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 100); stamper.addAnnotation(PdfAnnotation.createText(stamper.getWriter(), new Rectangle(300f, 350f, 500f, 450f), "inserted page", "This page contains a copy of the next three pages.", true, null), 1); List list = SimpleBookmark.getBookmark(reader); HashMap<String, String> map = new HashMap<String, String>(); map.put("Title", "title content"); map.put("Action", "GoTo"); map.put("Page", "1 FitH 806"); list.add(0, map); stamper.setOutlines(list); stamper.close(); }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, String> newmap = new HashMap<Integer, String>(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "from"); newmap.put(3, "java2s.com"); System.out.println(newmap.values()); }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, String> newmap = new HashMap<Integer, String>(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "from"); newmap.put(3, "java2s.com"); // check existence of key 2 System.out.println("Check if key 2 exists: " + newmap.containsKey(2)); }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, String> newmap = new HashMap<Integer, String>(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "from"); newmap.put(3, "java2s.com"); // check existence of value 'point' System.out.println("Check if value 'point' exists: " + newmap.containsValue("point")); }
From source file:HashDemoGeneric.java
public static void main(String[] args) { HashMap<Integer, String> map = new HashMap<Integer, String>(); map.put(1, "Ian"); map.put(42, "Scott"); map.put(123, "Somebody else"); String name = map.get(42);/* www . j a v a 2 s . co m*/ System.out.println(name); }
From source file:MainClass.java
public static void main(String args[]) { HashMap<String, Double> hm = new HashMap<String, Double>(); hm.put("A", new Double(3434.34)); hm.put("B", new Double(123.22)); hm.put("C", new Double(1378.00)); hm.put("D", new Double(99.22)); hm.put("E", new Double(-19.08)); Set<Map.Entry<String, Double>> set = hm.entrySet(); for (Map.Entry<String, Double> me : set) { System.out.print(me.getKey() + ": "); System.out.println(me.getValue()); }/* w w w . ja va 2 s. com*/ System.out.println(); double balance = hm.get("B"); hm.put("B", balance + 1000); System.out.println("B's new balance: " + hm.get("B")); }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, String> newmap = new HashMap<Integer, String>(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "from"); newmap.put(3, "java2s.com"); // get value of key 3 String val = (String) newmap.get(3); // check the value System.out.println("Value for key 3 is: " + val); }