Here you can find the source of toDouble(Object obj)
public static double toDouble(Object obj)
//package com.java2s; //License from project: Apache License public class Main { public static double toDouble(Object obj) { if (obj instanceof Integer) { return ((Integer) obj).doubleValue(); }//w w w . ja va2s . c o m if (obj instanceof Double) { return ((Double) obj).doubleValue(); } if (obj instanceof Long) { return ((Long) obj).doubleValue(); } if (obj instanceof Short) { return ((Short) obj).doubleValue(); } if (obj instanceof Byte) { return ((Byte) obj).doubleValue(); } if (obj instanceof Float) { return ((Float) obj).doubleValue(); } throw new IllegalArgumentException("can't cast to number " + obj); } }