Primitive Gosu types

Gosu supports the following Java primitive types, which are provided for compatibility with existing Java code. From Gosu, you can access the Java object versions (non-primitives) of the Java primitive types. For example, java.lang.Boolean is an object type that wraps the behavior of the boolean primitive. Primitive types perform better in terms of performance and space compared to their object versions.

The following table compares primitive types and object types.

Type

Primitive types

Object types

Extends from Object class

Can reference an object

A variable of this type could contain null at run time

Exposes methods

Exposes properties

Can be a member of a collection

The following table lists the Java primitives that you can access from Gosu. The table mentions IEEE 754, which is the Institute of Electrical and Electronics Engineers standard for binary floating-point arithmetic.

Primitive

Type

Value

boolean

Boolean value

true or false

byte

Byte-length integer

8-bit two’s complement

char

Single character

16-bit Unicode

double

Double-precision floating point number

64-bit (IEEE 754)

float

Single-precision floating point number

32-bit (IEEE 754)

int

Integer

32-bit two’s complement

long

Long integer

64-bit two’s complement

short

Short integer

16-bit two’s complement

See also