Consider the following code:
class AA { }
class BB extends AA { }
public class Testing {
public static void main(String[] args) {
BB[] arr = new B
BB[] does not extend AA[] even though BB extends AA. ArrayLists held Objects. so anything could be held in an ArrayList. If you had an Array of Object, you could play the same game. Now with generics you can specify an ArrayList with a specific type like ArrayList.actually the problem is on line 2:
AA[] arr2=arr;
Let's make the problem a little easier. You have a vehicle class and a bike and a car class that extends vehicle. You can not have
Bike b=new Bike()
Car c=b;
arr2 is an array and arr is an array, but the class is different. Does that help?