import java.util.*;
public class Test
{
public static void main(String [] args)
{
Integer x = 10;
Integer y = new Integer(10);
System.out.println(x);
System.out.println(y);
}
}
------ Solution ------------------------------------ --------
a reference to a value that is Integer, is assigned a value . And an object reference , he is assigned an address .
------ Solution ---------------------------------------- ----
and direct assignment and new String String is a reason
new words wasted memory
------ Solution ------------------------------ --------------
1st floor
public static void main(String[] args) {
Integer i1=10;
Integer i2=10;
Integer i3=new Integer(10);
Integer i4=128;
Integer i5=128;
System.out.println(i1==i2);//true
System.out.println(i1==i3);//false
System.out.println(i4==i5);//false
}
do not understand anything , do not look
Integer x = 10 ;/ / automatic packing , if between -128 to 127 , the value of the constant presence of the pool ( 10 ) ;/ / object ordinary heap
Integer y = new Integer
------ Solution ------------------------------------ --------
first performed automatic packing operation, with the second one is the same, so the two are the same
------ Solution ------ --------------------------------------
+1
------ For reference only -------------------------------- -------
Thank you , 3rd floor, very intuitive and clear explanations .
没有评论:
发表评论