Tag: SYS has a 16px post output out about the blog type conversion
One, for the storage of Java variables
The general variables are stored in stacks, heaps, and memory pools. Declared with new, it is generally placed in heap memory. Some basic types of variables and object reference variables are allocated in the function's stack memory. For a constant pool, like our usual string s1= "abc", the declared string object is stored in a constant pool.
String s1= "abc"; String s2= "abc"; string S3=new string ("abc"); System.out.println (S1= =s2); System.out.println (S1==s3);
The result of this output is true and false.
Ii. comparison of integers and int
1 integer a=new integer (+); 2 int b=128; 3 integer c=new integer (6); 4 integer d=new integer (6); 5 System.out.println (a==b); 6 System.out.println (C==d);
The result of the output is true and false
An int is a basic data type, and an integer is an object that points to an object with a reference.
There is a boxing and unpacking method between int and integer:
Packing:
// Packing // converting a base data type to an object
Unpacking:
// Packing Integer num=1; // Unpacking int // To convert an object to a base data type
Another point:
For the value of integer boxing, when Java defines a number from 128 to 127, it is boxed into an integer object, which is reused in memory and always has only one object of that value.
If the value is more than 128 or less than-127, a new integer object is newly.
Integer a=128; integer b=128; integer c=127; integer d=127; System.out.println (a= =b); Results falseSystem.out.println (c==d); Result Ture
A little bit of knowledge about Java