stackoverflow error in java

前端 未结 6 1951
南方客
南方客 2020-12-20 19:44

I\'m a newbie in java. I\'m writing a class where the constructor must check the price parameter and ensure it is not a negative number. And if it is negative, it must set

6条回答
  •  清酒与你
    2020-12-20 20:35

    Your getprice() method calls itself instead of checking price. This is leading to an infinite recursion in this case.

提交回复
热议问题