From 10ae230a618a3a9bd6eec33373642f818d428400 Mon Sep 17 00:00:00 2001 From: SnailClimb Date: Wed, 17 Jul 2019 17:20:17 +0800 Subject: [PATCH] =?UTF-8?q?Update=20Java=E7=96=91=E9=9A=BE=E7=82=B9.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "docs/java/Java\347\226\221\351\232\276\347\202\271.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/docs/java/Java\347\226\221\351\232\276\347\202\271.md" "b/docs/java/Java\347\226\221\351\232\276\347\202\271.md" index e13c982b..8abad01b 100644 --- "a/docs/java/Java\347\226\221\351\232\276\347\202\271.md" +++ "b/docs/java/Java\347\226\221\351\232\276\347\202\271.md" @@ -78,7 +78,7 @@ System.out.println(x == y);// true Integer a = new Integer(3); Integer b = new Integer(3); System.out.println(a == b);//false -System.out.println(a.equals(b));//false +System.out.println(a.equals(b));//true ``` 当使用自动装箱方式创建一个Integer对象时,当数值在-128 ~127时,会将创建的 Integer 对象缓存起来,当下次再出现该数值时,直接从缓存中取出对应的Integer对象。所以上述代码中,x和y引用的是相同的Integer对象。 -- GitLab