Online Java Compiler By
JavaTpoint.com
public class Double_shortValueMethodExample1 { public static void main(String[] args) { double d1=1240.7458; Double d2 =new Double(d1); // returning short value short d3=d2.shortValue(); System.out.println("1. "+d2+" after converted to short Value = "+d3); // passing negative integer Double d4= new Double(-1140.728); System.out.println("2. "+d4+" after converted to short Value = "+d4.shortValue()); Double d5= new Double(746587634.444444); System.out.println("3. "+d5+" after converted to short Value = "+d5.shortValue()); Double d6= new Double(0.746587634); System.out.println("4. "+d6+" after converted to short Value = "+d6.shortValue()); } }
Output