Java循环复杂map,foreach
程序员文章站
2022-06-29 12:54:29
...
package com.proxy.util; import java.util.HashMap; import java.util.Map; /** * @author: (le.qiao) * @e-mail: qiaolevip@gmail.com * @myblog: <a href="http://qiaolevip.iteye.com">http://qiaolevip.iteye.com</a> * @date: 2012-8-17 * */ public class XmlWriter { public static void main(String[] args) { Map<String, String> map = new HashMap<String, String>(); map.put("thirduserid", "24396353"); map.put("thirdorderid", "2012050893537966006"); Map<String, String> map2 = new HashMap<String, String>(); map2.put("singleprice", "0.1"); map2.put("quantity", "2"); Map<String, Map<String, String>> map3 = new HashMap<String, Map<String, String>>(); map3.put("orderinfo", map); map3.put("orderdeatil", map2); XmlWriter.write(map3); } public static String write(Map<String, Map<String, String>> map) { String reuslt = ""; StringBuffer sb = new StringBuffer(); sb.append("<api_respones xmlns:damaiapi=\"http://appapi.damai.cn/1.0\">\n"); if (map != null && map.size() > 0) { for (Map<String, String> map2 : map.values()) { for (String str : map2.values()) { System.out.println(str); } } } return reuslt; } }
上一篇: SQLPLUS的几个常用函数
下一篇: 几个常用的内置函数