首页 > 学院 > 开发设计 > 正文

一个有意思的问题

2019-11-11 02:38:14
字体:
来源:转载
供稿:网友

两段很有意思的代码

/** * 测试引用 */ @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 的数据差别,前面代码段输出两行结果不同,后面代码段结果相同


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表