Scala: Data Types Cheat Sheet

The data types that are available in Scala as shown in the below table:

DatatypeDefault valueDescription
BooleanFalseTrue or False
Byte08 bit signed value. Range:-128 to 127
Short016 bit signed value. Range:-215 to 215-1
Char‘\u000’16 bit unsigned unicode character. Range:0 to 216-1
Int032 bit signed value. Range:-231 to 231-1
Long0L64 bit signed value. Range:-263 to 263-1
Float0.0F32 bit IEEE 754 single-Precision float
Double0.0D64 bit IEEE 754 double-Precision float
StringnullA sequence of character
UnitCoinsides to no value.
NothingIt is a subtype of every other type and it contains no value.
AnyIt is a supertype of all other types
AnyValIt serve as value types.
AnyRefIt serves as reference types.

Leave a Reply

Your email address will not be published. Required fields are marked *