List of usage examples for java.util Map get
V get(Object key);
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.get("key2")); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { PdfReader reader = new PdfReader("2.pdf"); Map info = reader.getInfo(); for (Iterator i = info.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); String value = (String) info.get(key); System.out.println(key + ": " + value); }/* w w w . j av a 2 s .c om*/ if (reader.getMetadata() == null) { System.out.println("No XML Metadata."); } else { System.out.println("XML Metadata: " + new String(reader.getMetadata())); } }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.get("key2")); System.out.println(map.containsKey("key2")); System.out.println(map.containsKey("key4")); }
From source file:Main.java
public static void main(String[] args) { Map<Character, Integer> counting = new HashMap<Character, Integer>(); String testcase1 = "this is a test"; for (char ch : testcase1.toCharArray()) { Integer freq = counting.get(ch); counting.put(ch, (freq == null) ? 1 : freq + 1); }// w w w . jav a2 s .co m System.out.println(counting.size() + " distinct characters:"); System.out.println(counting); }
From source file:Main.java
public static void main(String[] args) { String yourString = "UNDERSTAND"; Map<Character, Integer> count = new TreeMap<Character, Integer>(); for (char c : yourString.toCharArray()) { if (count.containsKey(c)) { count.put(c, (int) count.get(c) + 1); } else {/*w ww .jav a2s .c om*/ count.put(c, 1); } } System.out.println(count); }
From source file:Main.java
public static void main(String args[]) { String s = "this is a test this is a test"; String[] splitted = s.split(" "); Map<String, Integer> hm = new HashMap<String, Integer>(); for (int i = 0; i < splitted.length; i++) { if (hm.containsKey(splitted[i])) { int cont = hm.get(splitted[i]); hm.put(splitted[i], cont + 1); } else {//from w w w. j a va 2 s .c o m hm.put(splitted[i], 1); } } System.out.println(hm); }
From source file:QueryProperties.java
public static void main(String[] args) { VirtualUniverse vu = new VirtualUniverse(); Map vuMap = vu.getProperties(); System.out.println("version = " + vuMap.get("j3d.version")); System.out.println("vendor = " + vuMap.get("j3d.vendor")); System.out.println("specification.version = " + vuMap.get("j3d.specification.version")); System.out.println("specification.vendor = " + vuMap.get("j3d.specification.vendor")); System.out.println("renderer = " + vuMap.get("j3d.renderer") + "\n"); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); /*/*from ww w .jav a2 s.c o m*/ * We need to set this to force choosing a pixel format that support the * canvas. */ template.setStereo(template.PREFERRED); template.setSceneAntialiasing(template.PREFERRED); GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template); Map c3dMap = new Canvas3D(config).queryProperties(); System.out.println("Renderer version = " + c3dMap.get("native.version")); System.out.println("doubleBufferAvailable = " + c3dMap.get("doubleBufferAvailable")); System.out.println("stereoAvailable = " + c3dMap.get("stereoAvailable")); System.out.println("sceneAntialiasingAvailable = " + c3dMap.get("sceneAntialiasingAvailable")); System.out.println("sceneAntialiasingNumPasses = " + c3dMap.get("sceneAntialiasingNumPasses")); System.out.println("textureColorTableSize = " + c3dMap.get("textureColorTableSize")); System.out.println("textureEnvCombineAvailable = " + c3dMap.get("textureEnvCombineAvailable")); System.out.println("textureCombineDot3Available = " + c3dMap.get("textureCombineDot3Available")); System.out.println("textureCombineSubtractAvailable = " + c3dMap.get("textureCombineSubtractAvailable")); System.out.println("texture3DAvailable = " + c3dMap.get("texture3DAvailable")); System.out.println("textureCubeMapAvailable = " + c3dMap.get("textureCubeMapAvailable")); System.out.println("textureSharpenAvailable = " + c3dMap.get("textureSharpenAvailable")); System.out.println("textureDetailAvailable = " + c3dMap.get("textureDetailAvailable")); System.out.println("textureFilter4Available = " + c3dMap.get("textureFilter4Available")); System.out .println("textureAnisotropicFilterDegreeMax = " + c3dMap.get("textureAnisotropicFilterDegreeMax")); System.out.println("textureBoundaryWidthMax = " + c3dMap.get("textureBoundaryWidthMax")); System.out.println("textureWidthMax = " + c3dMap.get("textureWidthMax")); System.out.println("textureHeightMax = " + c3dMap.get("textureHeightMax")); System.out.println("textureLodOffsetAvailable = " + c3dMap.get("textureLodOffsetAvailable")); System.out.println("textureLodRangeAvailable = " + c3dMap.get("textureLodRangeAvailable")); System.out.println("textureUnitStateMax = " + c3dMap.get("textureUnitStateMax")); System.out.println( "compressedGeometry.majorVersionNumber = " + c3dMap.get("compressedGeometry.majorVersionNumber")); System.out.println( "compressedGeometry.minorVersionNumber = " + c3dMap.get("compressedGeometry.minorVersionNumber")); System.out.println("compressedGeometry.minorMinorVersionNumber = " + c3dMap.get("compressedGeometry.minorMinorVersionNumber")); System.exit(0); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Map objMap = new IdentityHashMap(); Object o1 = new Integer(123); Object o2 = new Integer(123); objMap.put(o1, "first"); objMap.put(o2, "second"); Object v1 = objMap.get(o1); // first Object v2 = objMap.get(o2); // second }
From source file:Main.java
public static void main(String[] argv) { Map<String, URL> urlMap = new HashMap<String, URL>(); try {/*from w w w.j a va 2 s.co m*/ urlMap.put("java", new URL("http://www.java2s.com")); } catch (MalformedURLException e) { } String s = urlMap.get("java").getHost(); }
From source file:Freq.java
public static void main(String[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); // Initialize frequency table from command line for (String a : args) { Integer freq = m.get(a); m.put(a, (freq == null) ? 1 : freq + 1); }/*from ww w. j a v a2s. c om*/ System.out.println(m.size() + " distinct words:"); System.out.println(m); }