- Java data types are divided into two main categories,
Basic data types
|------Numerical Type
|------integer type (byte,int,short,long)
|------Floating-point type (float,double)//floating-point notation for decimals
|------character type (char)
|------Boolean Type (Boolean)
Reference data type
|------Class (CALSS)
|------interface (INTERFACE)
|------Array
The value length of the base data type
Long (length integer)
Value range: Maximum value: 9223372036854775807 ~ Minimum Value: 9223372036854775808
Long Maxlong=long.max_value;long Minlong=long.min_value; System.out.println ("Long type, maximum value:" +maxlong); System.out.println ("Long type, minimum value:" +minlong);
Int (integer)
Value range: Maximum value: 2147483647~2147483648
int intmax=integer.max_value; SYSTEM.OUT.PRINTLN ("int type, maximum value:" +intmax); SYSTEM.OUT.PRINTLN ("int type, Minimum value:" + (intmax+1));
Integer maximum plus 1 will become the minimum value.
Principle:
Short (shorter integer)
Value range: Maximum value: 32767~ Minimum: 32768
BYTE (bit)
Value range: Maximum value: 127 ~ Minimum: 128
char (character)
Value range: Maximum value: 255~ Minimum: 0
Float (single precision)
Value range: Maximum value: 3.4e38~ Minimum: -3.4E38
Double (dual precision)
Value range: Maximum value: 1.7E308 min.: -1.7E308
The problem occurs when the value exceeds its range of values.
For example: int a=9999999999999999; Will compile will not pass. It will tell you that the int type is out of range
The conversion of the data type.
Automatic conversion: The data type before conversion is compatible with the converted type, and the transformed data type is larger than the type before the conversion.
Cast: (data type to convert) variable name
int a=10;//defines an integral type a value variable float b=3.0f;//defines a floating-point B-value variable of 3.3fsystem.out.println ("a+b=" + (a+b));//auto-upward to floating-point. System.out.println ("a/b=" + (A/b));//auto-upward to floating-point. int C=8;int d=3; System.out.println ("8/3=" +c/d);//The normal answer is 2.66666666 ... If it is//the banking business needs to involve several decimal places. Here is the System.out.println ("forced transformation-------------under the---------------"); System.out.println ((float) C/D);//Forced transformation.
Any of these types will be converted to string.
Java Data types