The code given below shows a Stackoverflow error when run.But if I make another class CarChange to create objects of Car ,it runs sucessfully. I am a beginner ,doing this code t
Car() {
c[0] = new Polo();
i=0;
}
As Polo is a subclass of Car() - it must be to fit in the Car[] - it will call the Car's constructor when being constructed itself. The Car constructor tries to create a new Polo().
As Polo is a subclass of Car() - it must be to fit in the Car[] - it will call the Car's constructor when being constructed itself. The Car constructor tries to create a new Polo().
As Polo is a subclass of Car() - it must be to fit in the Car[] - it will call the Car's constructor when being constructed itself. The Car constructor tries to create a new Polo().
... you get the picture?