There are two types of data in Java:
1. Basic type: Long,int,byte,float,double,char
2. Object type (Class): long,integer,byte,float,double,char,string, everything else provided by Java, or a class you create yourself.
Where long is also called Long of the wrapper class. Byte and float are similar, and the first name of the generic wrapper class is the beginning of the capitalization of the numeric name.
What is the packing class?
in Java, sometimes the operation must be between two classes of objects, do not allow the operation between the object and the number. So there needs to be an object that wraps the numbers so that the object can be operated on with another object.
For example, we can also define a class:
class Long {
int i=0;
Public Long (int i) {
this.i=i;
}
}
So this integer is a wrapper class, he wraps an integer value, and can then write some operator overloading in it to support some operations. You can assign a value at this time:
Long It=new long (10);
Now variable it is an object, not a number.
Long is an integer, in how long itself is also integral type, 12.10 of the shaping part is 12, of course, the result is 12,
BYTE: A eight-bit integer -128--127 that can be used to save memory.
Short:16 bit integer -32768--32,767, also compared to save memory.
Int:32 bit integer -2,147,483,648--2,147,483,647, in general, integers are sufficient.
long:64 bit integer -9,223,372,036,854,775,808--9,223,372,036,854,775,807, generally not required
Float:32 bit floating point, if floating point needs to save memory with this.
double:64 bit floating point, generally non-integer floating point can be used this.
What is the difference between long and long in Java?