import java.util.*;
public class J1
{
public static void main(String[] args)
{
class a1 { public String toString() { return "a1";} }
class b extends a1 { public String toString() { return "b";} }
class c extends a1 { public String toString() { return "c";} }
class d extends a1 { public String toString() { return "d";} }
List<a1> l1 = new ArrayList<a1>();
l1.add(new a1());
l1.add(new b());
l1.add(new c());
l1.add(new d());
// l1.
List<b> l2 = new ArrayList<b>();
l2.add(new b());
l2.add(new b());
for (a1 a : l1)
{
// to nie dziala
// B b = a;
// l2.add(a);
}
// l2 = l1;
for(b b : l2)
{
l1.add(b);
}
System.out.println("l1:" + l1);
for (a1 a: l1)
{
System.out.println("l1.a:" + a);
}
// l1 = l2;
// l2 = l1;
l2 = (List)l1;
System.out.println("l2:" + l2);
List l3 = l1;
for (a1 b: l2)
{
System.out.println("l2.b:" + b);
}
l1 = (List)l2;
System.out.println("l1:" + l2);
}
}
l1:[a1, b, c, d, b, b]
l1.a:a1
l1.a:b
l1.a:c
l1.a:d
l1.a:b
l1.a:b
l2:[a1, b, c, d, b, b]
l2.b:a1
l2.b:b
l2.b:c
l2.b:d
l2.b:b
l2.b:b
l1:[a1, b, c, d, b, b]