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> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); Object obj = hMap.remove("2"); System.out.println(obj + " Removed from HashMap"); }
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"); hMap.clear();/* w w w .java2 s . c o m*/ System.out.println(hMap.size()); }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("4", "four"); hm.put("3", "three"); hm.put("1", "one"); hm.put("2", "two"); Map<String, String> treeMap = new TreeMap<String, String>(hm); System.out.println(treeMap);/*from ww w . j a v a 2 s . c o m*/ }
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"); boolean blnExists = hMap.containsKey("3"); System.out.println("3 exists in HashMap ? : " + blnExists); }
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(10, 0.75F); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map);/*from w ww . j av a 2 s.c o m*/ }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();/* w w w . j av a 2 s. c o m*/ document.add(new Paragraph("Hello World")); document.close(); PdfReader reader = new PdfReader("2.pdf"); System.out.println("Tampered? " + reader.isTampered()); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("2.pdf")); HashMap info = reader.getInfo(); info.put("Subject", "subject"); info.put("Author", "author"); info.put("Keywords", "keywords"); info.put("Title", "title"); info.put("Creator", "creator"); stamper.setMoreInfo(info); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XmpWriter xmp = new XmpWriter(baos, info); xmp.close(); stamper.setXmpMetadata(baos.toByteArray()); stamper.close(); }
From source file:Main.java
public static void main(String args[]) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); map.put(1, 2); map.put(2, 3);/* w w w . j a v a 2 s . c o m*/ map.put(3, 4); for (Integer key : map.keySet()) { System.out.println(map.get(key)); } }
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); Collection set = map.values(); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/*from w w w . j a va 2s . com*/ }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("3", "three"); hm.put("1", "one"); hm.put("4", "four"); hm.put("2", "two"); printMap(hm);// w w w. j av a2 s . com }
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); map.put(null, null);/*from w w w.j a va2s . c o m*/ HashMap<String, String> map2 = new HashMap<String, String>(); map2.put("key4", "value4"); map2.put("key5", "value5"); map2.put("key6", "value6"); map.putAll(map2); System.out.println(map); }