Truncation in Java refers to the process of reducing or shortening a value, typically a floating-point number, by removing its fractional part. This often occurs when converting a double or float to an integer type (int or long). Truncation simply drops everything after the decimal point without rounding.
For example:
java
double value = 5.99;
int truncatedValue = (int) value; // Result: 5
In this case, the number 5.99 is truncated to 5 because the fractional .99 is discarded. Truncation is useful in scenarios where only the whole number portion of a value is needed, but it may lead to a loss of precision.