List of usage examples for java.util Map get
V get(Object key);
From source file:MainClass.java
public static void main(String[] a) { Map map = new HashMap(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); System.out.println(map.get("key2")); }
From source file:org.freakz.hokan_ng_springboot.bot.Application.java
public static void main(String[] args) { CommandLineArgsParser parser = new CommandLineArgsParser(args); Map<CommandLineArgs, String> parsed = parser.parseArgs(); String url = parsed.get(CommandLineArgs.JMS_BROKER_URL); if (url != null) { JMS_BROKER_URL = url;// ww w.jav a 2 s .com } log.debug("JMS_BROKER_URL: {}", JMS_BROKER_URL); SpringApplication.run(Application.class, args); }
From source file:Main.java
public static void main(String[] args) throws Exception { String bubba = "this is a test this is a test"; Map<Integer, Integer> occurrences = new HashMap<Integer, Integer>(); for (String currentWord : bubba.split(" ")) { Integer current = occurrences.get(currentWord.length()); if (current == null) { current = 0;//w w w .j ava 2 s . co m } occurrences.put(currentWord.length(), current + 1); } for (Integer currentKey : occurrences.keySet()) { System.out.println("There are " + occurrences.get(currentKey) + " " + currentKey + " letter words"); } }
From source file:Main.java
public static void main(String[] args) { // create a new list of arguments for our process String[] list = { "notepad.exe", "test.txt" }; // create the process builder ProcessBuilder pb = new ProcessBuilder(list); // get the environment of the process Map<String, String> env = pb.environment(); // get the system drive of the environment System.out.println(env);/* w w w.j a v a2 s. c o m*/ System.out.println(env.get("SystemDrive")); }
From source file:com.mmj.app.common.util.URLUtils.java
public static void main(String[] args) throws MalformedURLException { String subway_url = "http://detail.tmall.com/item.htm?spm=a1z10.4.w5003-3705396631.2.aiPsIi&id=22490775015&&mt=&&scene=taobao_shop"; Map<String, Object> params = getParams(new URL(subway_url)); System.out.println(params);// ww w. j a va 2 s . c om System.out.println(params.get("token")); }
From source file:com.alibaba.dubbo.examples.redis.RedisConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = RedisConsumer.class.getPackage().getName().replace('.', '/') + "/redis-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();/*from w w w . j ava2 s.c om*/ Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value); if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } }
From source file:com.joshlong.examples.data.counter.Main.java
public static void main(String[] args) throws Throwable { ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/counter.xml"); Map<String, Counter> counters = ac.getBeansOfType(Counter.class); for (String beanName : counters.keySet()) exercise(beanName, counters.get(beanName)); }
From source file:Counter.java
public static void main(String[] args) { Map hm = new HashMap(); for (int i = 0; i < 10; i++) { Integer r = new Integer(20); if (hm.containsKey(r)) ((Counter) hm.get(r)).i++; else/*from w ww.j av a 2s.c o m*/ hm.put(r, new Counter()); } System.out.println(hm); }
From source file:com.alibaba.dubbo.examples.memcached.MemcachedConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = MemcachedConsumer.class.getPackage().getName().replace('.', '/') + "/memcached-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();/*from w w w. java 2s. c om*/ Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value); if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } System.in.read(); }
From source file:Main.java
public static void main(String[] args) { Map errors = new HashMap(); errors.put("404", "A."); errors.put("403", "B."); errors.put("500", "C."); String errorDesc = (String) errors.get("404"); System.out.println("Error 404: " + errorDesc); Iterator iterator = errors.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); System.out.println("Error " + key + " means " + errors.get(key)); }// ww w.j a v a2 s . c o m }