7.1. The Java Value Type
The Java value type is also known as the primitive data type. Table 7.1 shows the Java primitives.
Variables can be declared as a primitive type. Depending on the scope where they are declared, they must be initialized. For example, you must initialize local method variables as shown here:
int age = 10; long population = 100000L; float price = 12.45f; double count = 6.45d;
Keyword | Description | Size/Format |
---|---|---|
Byte | Byte-length integer | 8 bits |
Short | Short integer | 16 bits |
Int | Integer | 32 bits |
Long | Long integer | 64 bits |
Float | Single-precision floating point | 32-bit IEEE 754 |
Double | Double-precision floating point | 64-bit IEEE 754 |
Char | A single character | 16-bit Unicode character |
Boolean | A Boolean value | True or false |
Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.