Java Primitive Data Types
Download (.odt) Download (Markdown)Numeric data types
Whole numbers
byte (from -128 to 127, stored on 8 bit):
byte num = 100;
        short (from -32,768 to 32,767, stored on 16 bit):
short num2 = 20000;
        int (from -2,147,483,648 to 2,147,483,647, stored on 32 bit):
int num3 = 200000000;
        long (from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, stored on 64 bit):
long num4 = 200000000000000L;
        Decimal numbers
float (up to 6-7 decimal digits, stored on 32 bit):
float num5 = 10.8241f;
float num6 = 10.8241e2f; // 1082.41
        double (up to 15-16 decimal digits, stored on 64 bit):
float num7 = 20.8123819238912d;
float num8 = 20.8123819238912e3d; // 20812.3819238912
      Other primitive data types
boolean (true or false):
boolean bool = true;
        character (a single character in single quotes, or an ASCII value):
char character = 'A';
char ascii = 65;