3- Java Data Types
3- Java Data Types
CHAPTER - III
STRONGLY T YPED DATA T YPE
• In java, every variable & every expression has some type.
• Each and every data type is clearly defined.
• Every assignment should be checked by the compiler for type compatibility.
• Because of the above reasons, we can conclude Java language is a strongly typed programming
language.
• Ruby
• Scala
• Eiffel
Primitive
Data Type
(8)
Non-
Numeric
Numeric
Floating
Integer char boolean
point
1 1 … 1 1 1 1 … 1 1
0 → +ive 0 → +ive
1 → -ive 1 → -ive
• Max Value → +2,14,74,83,647 (231-1) • Max Value → +92,23,37,20,36,85,47,75,807(264-1)
• Min Value → -2,14,74,83,648 (231) • Min Value → -92,23,37,20,36,85,47,75,808 (264)
• Range → -2,14,74,83,648 to +2,14,74,83,647 • Range → -92,23,37,20,36,85,47,75,808 to
+92,23,37,20,36,85,47,75,807
float double
• Used when 5-6 places decimal accuracy is • Used when 14-15 places decimal accuracy is
needed. needed.
• It is a single precision data type • It is a double-precision data type
• The size is 4 bytes • The size is 8 bytes
• Range: -3.4e38 to 3.4e38 • Range: -1.7e308 to 1.7e308
• Ex: 3.4f, 56.69f • Ex: 3.4, 56.69d
• Note: The default data type for decimal values is • Note: The default data type for decimal values is
double. To take float input, explicitly ‘f’ or ‘F” is to double so, explicitly ‘d’ or ‘D” may be added after
be added after the number as a suffix. the number as a suffix but not compulsory.