Java has a total of 8 basic data types, respectivelyInteger: Byte (Byte), short (shorter), long (Long Integer), int (integer) decimal type: Float (single-precision floating-point type), double (double-precision floating-point type) Character: Char Boolean: Boolean Eight basic data type parameter tables
Note: (1) If you write a long type value, you need to add the letter L after the value, both uppercase and lowercase (2) The value range of the decimal type is described in scientific notation (3) Float type decimal, need to add letter F after decimal, case-insensitive, such as 4.09f or 4.09F (4) The amount of space that a Boolean takes up depends on the implementation of the Java Virtual Machine (JVM), possibly 1bit, or 8bit.
Use statements to view the space code used by a data type is as follows: You need to find an encapsulation type of each data type to get their footprint.
public class Yufa {
/**
* @param args */public
static void Main (string[] args) {
//TODO Auto-generat Ed method stub
//need to find each type of encapsulation type
int a=byte.size;
int b=short.size;
int c=integer.size;
int d=long.size;
int e=float.size;
int f=double.size;
int g=character.size;
System.out.println ("Occupied space of byte type--" +a/8+ "byte--");
System.out.println ("The short type occupies the space-" +b/8+ "bytes--");
System.out.println ("Occupied space of int type-" +c/8+ "bytes--");
System.out.println ("Occupied space of long type--" +d/8+ "bytes--");
System.out.println ("float-type occupancy space-" +e/8+ "bytes--");
System.out.println ("Occupy space of double type--" +f/8+ "bytes--");
System.out.println ("Char-occupied space-" +g/8+ "bytes--");
}