Online Java Compiler By
JavaTpoint.com
public class FloatShortValueExample1 { public static void main(String[] args) { float f1=40.78f; Float f2 =new Float(f1); // returning short value float f3=f2.shortValue(); System.out.println("1. "+f2+" after converted to short Value = "+f3); // passing negative integer Float f4= new Float(-40.78); System.out.println("2. "+f4+" after converted to short Value = "+f4.shortValue()); Float f5= new Float(746587634.444444); System.out.println("3. "+f5+" after converted to short Value = "+f5.shortValue()); Float f6= new Float(0.746587634); System.out.println("4. "+f6+" after converted to short Value = "+f6.shortValue()); } }
Output