Language syntax
Primitive numeric casts
An explicit conversion between compatible numeric primitive types. Integral narrowing can discard high bits; floating-point to int truncates in-range values and handles NaN and out-of-range values by defined conversion rules. Casts are not validation.
Formal Syntax & Structure
java syntaxjava
(TargetPrimitiveType) expressionWorking Example
Example Snippetjava
public class Main { public static void main(String[] args) { long recorded = 4_294_967_301L; System.out.println((int) recorded); System.out.println((int) 7.99); }}