JAVA包装类及自动封包解包实例代码
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:publicclassWrapper{publicstaticvoidmain(String[]args){inti=50...
复制代码 代码如下:
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