In this example we will show you how to narrow Casting in Java.
Source Code
package com.beginner.examples;
public class NarrowCasting {
public static void main(String[] args) {
float f = 10.16f;
int i = (int) f; // narrow casting: float to int
System.out.println(f);
System.out.println(i);
}
}
Output:
10.16
10