What are the eight basic data types that are available in the course of our interview or exam with eight basic data types and their encapsulation classes? What are their encapsulation classes?
First, the eight basic data types are: int, short, float, double, long, Boolean, Byte, Char, and their encapsulated classes are: Integer, short, float, double, long, Boolean , Byte, Character.
Because encapsulated classes have methods and properties that can be used to handle data after encapsulation of the base data type, such as the Ingeter object has parseint (string s), the string can be converted to an int type, and so on. We all know that some types of data have default values, the base data type is not the same as the default value of the encapsulated type, such as int i, if I defaults to 0, but integer j, and if not, J is null because the encapsulated class produces an object and the default value of the object is null.
The tip:string type is not a basic data type, it is actually final decorated, and therefore cannot be inherited.
A variable of type string usually has two types of assignment: a direct assignment, such as String a = "Hello World", and a construction method, such as String b = new string ("Hello World"), so that A and B are equal. What difference do they have?
If you compare them with =, they are not equal because "=" compares whether the value of the base data type is equal or if the object is the same object, and the variable A and the variable B point to two different objects, why do you say so? To understand the assignment process of 2 variables, for the expression string a = "Hello World", you first create a string object "Hello World", which is actually placed in a string buffer and then points a to the object, and the string b = New string ("Hello World"); two objects one is "Hello World", which is placed in the string buffer, and the other is the object new string () that is constructed by the new method, which holds "Hello World object, this object is placed in heap memory, and b points to the new String () object, which is obviously a different two objects, so they use "=" to compare the result to false.
If compared with the Equals () method, this result is true because the Equals () method compares the contents of the objects, and their contents are "Hello World".
It is also worth reminding that the string buffer will only be saved once for the same string. If we write string a = "Hello World"; string b = new string ("Hello World"), then the string buffer actually has only one Hello World string, and when assigned to B, the string buffer is first checked for The "Hello World" string, if there is one, is not created, is directly new string (), and then assigns a value, so in this case, the expression string b= new string ("Hello World") also creates only one object.
Reproduced from: http://www.cnblogs.com/wanghang/p/6298924.html