Variables Most Often Used
 
Data Type  Java Keyword  Kind of Value  Bytes of Memory  Range of Values
Character  char  1 character - Unicode 2   not applicable
Byte byte integer 1 -128 to127
 
Short integer  short   Integers  2 -32,768 to 32,767
(-215 to 215 - 1)
 
Integer  int  Integers 4   -2,147,483,648 to 2,147,483,647
(-231 to 231 - 1)
Long Integer   long  Integers 8 -9223372036854775808 to
9223372036854775807
(-263 to 263 - 1)
Float float  Decimal values to 7 decimal digit precision   4 3.4e-38 to 3.4e38
 positive and negative
 
Double double Decimal values to 15 decimal digit precision  8 1.7e-308 to 1.73e308
 positive and negative
 
Boolean  bool  Boolean (Logical) values
True or False 
1 not applicable
Rules for assigning variables: Assign short, int or long data types when you are sure a variable is a whole number (NO decimal points). Which type you choose depends upon the size of the numbers. Assign float or double when decimals are needed. Which type you choose depends upon the size of the numbers. Assign char if the variable will always contain only ONE character of data.
(c) Shilpa Sayura Foundation 2006-2017