Stackoverflow error

后端 未结 3 612
Happy的楠姐
Happy的楠姐 2021-01-21 14:29

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

3条回答
  •  [愿得一人]
    2021-01-21 15:09

    A stackoverflow usually means you have an infinite loop.

    The reason you're receiving this is because you're calling drive from the testdrive method and in that method you're calling drive again.

提交回复
热议问题