stackoverflow error in java

前端 未结 6 1963
南方客
南方客 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:50

    Your getprice should simply be written as :

    return price < 0 ? 0 : price;
    

    Btw, nice to see that a stackoverflow error is solved by stackoverflow.com

提交回复
热议问题