Please enable JavaScript to use CodeHS

CodeHS Glossary


Casting Java

Casting is turning something of one type into another type.

For example:

// x is an integer
int x = 5;

// y is a double with the value 5.0
double y = (double) x;
// x is a double
double x = 10.9;

// y is an int with the value 10
int y = (int) x;