Appendix D. Some Java details

Java data types

Java knows two kinds of types: primitive types and object types. Primitive types are stored in variables directly, and they have value semantics (values are copied when assigned to another variable). Object types are stored by storing references to the object (not the object itself). When assigned to another variable, only the reference is copied, not the object.

Primitive types

The following table lists all the primitive types of the Java language:

Type name

Description

Example literals

Integer numbers

    

byte

byte-sized integer (8 bit)

24

–2

 

short

short integer (16 bit)

137

–119

 

int

integer (32 bit)

5409

–2003

 

long

long integer (64 bit)

423266353L

55L

 

Real numbers

    

float

single-precision floating point

43.889F

  

double ...

Get Introduction to Programming with Greenfoot: Object–Oriented Programming in Java™ with Games and Simulations, First Edition 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.