- float => int
class GFG{
public static void main(String[] args) {
int[] arr = {1,2,3};
int a = test(0,3);
System.out.println(arr[a]);
}
public static int test(int low,int hight){
return low + (hight-low)/2;
}
}
- int => float
The data type of int and float have the same size (32 bits), but they can be displayed in two ways. When we cascate float to int, it will lose presicision.