Numeric data types are used to store numbers. There are four primitive data types that store integer values:
|Type||Size (in bytes)||Minimum||Maximum|
There are two primitive data types that store decimal values (numbers with a fraction part):
|Type||Size (in bytes)||Precision (Decimal Digits)|
|float||4||Single (about 6)|
|double||8||Double (about 15)|
Character data consists of letters, numerals, punctuation, and some additional characters (such as tab, form feed, new line, and carriage return). There are two character data types:
|char||A primitive data type. Stores a single character.|
|String||A class. Stores a sequence of characters.|
While the string data type is included on this page, it is actually far from primitive. The String class has many very useful methods that allow us to manipulate strings of text. It is a primitive data type in the sense that it is already part of the Java language rather than a data structure that we have to devise ourselves.
The logical data type is named boolean and a logical variable stores the value true or false.