JAVA包装类及自动封包解包实例代码
作者:
JAVA包装类及自动封包解包实例代码,需要的朋友可以参考一下
复制代码 代码如下:
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