Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because your IDE (misleadingly, in this case) sees a possible autoboxing.</p> <p>For instance, if you create a <code>List&lt;Integer&gt;</code>, you can add an <code>int</code> to it: there is autoboxing from <code>int</code> to <code>Integer</code>. Unxobing is the reverse: <code>Integer</code> to <code>int</code>. Note that both boxing and unboxing only apply to numeric primitive types (BUT NOT to <em>arrays</em> of them).</p> <p>Here, there is no doubt that the method with <code>double</code> will be chosen eventually (since it is more specific), but your IDE considers that there exists a possible ambiguity.</p> <p>This example code:</p> <pre><code>public final class Test { public static void item(Object a, Object b, String c, String d) { System.out.println("Object"); } public static void item(double a, double b, String c, String d) { System.out.println("double"); } public static void unbox(final double d) { System.out.println("Unboxed!"); } public static void useIt(double a, double b, Double c, Double d) { // primitives item(a, b, "", ""); // cast to corresponding classes item((Double) a, (Double) b, "", ""); // objects item(c, d, "", ""); // unboxed by the "unbox" method which takes a "double" as an argument unbox(new Double(2.0)); } public static void main(final String... args) { // Autoboxing of the third and fourth argument useIt(1.0, 1.0, 1.0, 1.0); } } </code></pre> <p>outputs:</p> <pre><code>double Object Object Unboxed! </code></pre> <p>Note however that you cannot call:</p> <pre><code>useIt((Double) a, b, c, d); // No autoboxing of "b" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload