两段很有意思的代码
/** * 测试引用 */ @Test public void testYinyong() { Map<String, Object> map = new HashMap<String, Object>(); JSONObject json = new JSONObject(); json.put("t1", "t1"); map.put("json", json); System.out.PRintln(map); json.put("t2", "t2"); System.out.println(map); } /** * 测试引用 */ @Test public void testYinyongV2() { Map<String, String> map = new HashMap<String, String>(); JSONObject json = new JSONObject(); json.put("t1", "t1"); map.put("json", json.toString()); System.out.println(map); json.put("t2", "t2"); System.out.println(map); }同样代码,只是map 的数据差别,前面代码段输出两行结果不同,后面代码段结果相同
新闻热点
疑难解答