兩段很有意思的代碼
/** * 測試引用 */ @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 的數據差別,前面代碼段輸出兩行結果不同,后面代碼段結果相同
新聞熱點
疑難解答