Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Java

Type Casting in Java

Convert between types with widening and narrowing casts.

Type Casting in Java — a practical guide to Java type casting with clear examples you can reuse in real projects.

Java Tutorial Series (12/90). Prefer one article? Read the complete Java tutorial.

Short description

Widening is safe/automatic (int→long). Narrowing needs an explicit cast and may lose data.

Casting

int a = 10;
double b = a;      // widening
int c = (int) 9.8; // narrowing → 9

Leave a reply

Your email address will not be published. Required fields are marked *