title: Java Double Object initialization with other Number type objects
body: <p>In <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html" rel="nofollow noreferrer">Double object documentation</a> it only have two constructors, one taking a double value and one taking a string value. However, I just found that if we initialize it with other Number type objects it will also work. For example the following code will work:</p>
  
  <pre><code>Integer i = Integer.valueOf(10);
  Double d1 = new Double(i);
  Long l = Long.valueOf(100);
  Double d2 = new Double(l);
  </code></pre>
  
  <p>So I'm wondering what's behind that? Autoboxing/unboxing would do the conversion between Double/double, Long/long and Integer/int, but I don't see why the constructor of Double will take other data types.</p>