GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaSourceCode/test/java/lang/IntegerTest2.java at main · Kelab/JavaSourceCode

Expand file tree

/

IntegerTest2.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
19 lines (18 loc) · 832 Bytes
/

IntegerTest2.java

Copy path

File metadata and controls

19 lines (18 loc) · 832 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package java.lang;
/**
* 当一个 Integer 和 int 比较时,Integer 会调用 intValue() 方法自动拆箱后再比较
*
* @author wupx
* @date 2020/04/27
*/
public class IntegerTest2 {
public static void main(String[] args) {
Integer i1 = new Integer(5);
Integer i2 = new Integer(5);// 通过 new 来创建的两个 Integer 对象
Integer i3 = 5;// 调用 valueOf 将 5 自动装箱成 Integer 类型
int i4 = 5;// 基本数据类型 5
System.out.println(i1 == i3); // false,两个引用没有引用同一对象
System.out.println(i1 == i2); // false,两个通过 new 创建的 Integer 对象不是同一个引用
System.out.println(i3 == i4); // true,i3 调用 java/lang/Integer.intValue:()I 自动拆箱成 int 类型再和 i4 比较
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.