Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The answer is no, according to the Java language specification, below. See the <strong>bold</strong> text.</p> <blockquote> <p>Assignment of a value of compile-time reference type S (source) to a variable of compile-time reference type T (target) is checked as follows: </p> <p>If S is a class type:</p> <ul> <li><strong>If T is a class type, then S must either be the same class as T, or S must be a subclass of T, or a compile-time error occurs.</strong></li> <li>If T is an interface type, then S must implement interface T, or a compile-time error occurs.</li> <li>If T is an array type, then a compile-time error occurs. </li> </ul> <p>If S is an interface type: </p> <ul> <li>If T is a class type, then T must be Object, or a compile-time error occurs. </li> <li>If T is an interface type, then T must be either the same interface as S or a superinterface of S, or a compile-time error occurs. </li> <li>If T is an array type, then a compile-time error occurs. </li> </ul> <p>If S is an array type SC[], that is, an array of components of type SC: </p> <ul> <li>If T is a class type, then T must be Object, or a compile-time error occurs. </li> <li>If T is an interface type, then a compile-time error occurs unless T is the type java.io.Serializable or the type Cloneable, the only interfaces implemented by arrays. </li> <li><p>If T is an array type TC[], that is, an array of components of type TC, then a compile-time error occurs unless one of the following is true: </p> <ul> <li>TC and SC are the same primitive type. </li> <li>TC and SC are both reference types and type SC is assignable to TC, as determined by a recursive application of these compile-time rules for assignability.</li> </ul></li> </ul> </blockquote>
 

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