JAVA包装类及自动封包解包实例代码
程序员文章站
2023-11-24 15:52:46
复制代码 代码如下:public class wrapper { public static void main(strin...
复制代码 代码如下:
public class wrapper {
public static void main(string[] args) {
int i = 500;
integer t = new integer(i);
int j = t.intvalue();
string s = t.tostring();
system.out.println(t);
integer t1 = new integer(500);
system.out.println(t.equals(t1));
integer a1 = 5;
int a2 = new integer(5);
system.out.println("a1 = " + a1 + ",a2 = " + a2);
}
}
结果:
d:\javacode>javac wrapper.java
d:\javacode>java wrapper
500
true
a1 = 5,a2 = 5