Element level promotions are applicable or not at array level?
class Array20
{
public static void main(String[] args)
{
int[] i={10,20,30,40};
char[] ch={'a','b','c','d'};
int[] b=ch;
System.out.println(b);
}
}
/*
Output:- CE[incompatible types]
Explanation:- Element level promotions are not applicable at array level.
For Example:- char element can be promoted to int type but char[]
cannot be promoted to int[].
*/
{
public static void main(String[] args)
{
int[] i={10,20,30,40};
char[] ch={'a','b','c','d'};
int[] b=ch;
System.out.println(b);
}
}
/*
Output:- CE[incompatible types]
Explanation:- Element level promotions are not applicable at array level.
For Example:- char element can be promoted to int type but char[]
cannot be promoted to int[].
*/
0 comments: