Is this possible to assigned child class type array to parent class type array?
class Array21
{
public static void main(String[] args)
{
String[] s={"A","B","C","D"};
Object[] o=s;
for(Object x:o)
System.out.println(x);
}
}
/*
Output:- A B C D
Explanation:- But in case of object type arrays, child class type array can be assigned
to its parent class type arrays.
*/
{
public static void main(String[] args)
{
String[] s={"A","B","C","D"};
Object[] o=s;
for(Object x:o)
System.out.println(x);
}
}
/*
Output:- A B C D
Explanation:- But in case of object type arrays, child class type array can be assigned
to its parent class type arrays.
*/
0 comments: