public class Main {
public static void main(String[] args) {
// Create two Integer objects using constructors
/*来自
N o w J a v a . c o m - 时 代 Java*/
Integer iv1 = new Integer(25);
Integer iv2 = new Integer(25);
System.out.println("iv1 = iv1 = " + iv1 + ", iv2 = " + iv2);
// Compare iv1 and iv2 references
System.out.println("iv1 == iv2: " + (iv1 == iv2));
// Let us see if they are equal in values
System.out.println("iv1.equals(iv2): " + iv1.equals(iv2));/*from 时 代 J a v a - N o w J a v a . c o m*/
System.out.println("\nUsing the valueOf() method:");
// Create two Integer objects using the valueOf()
Integer iv3 = Integer.valueOf(25);
Integer iv4 = Integer.valueOf(25);
System.out.println("iv3 = " + iv3 + ", iv4 = " + iv4);
// Compare iv3 and iv4 references
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。