In Java, how does a post increment operator act in a return statement?

前端 未结 5 1173
忘了有多久
忘了有多久 2020-12-11 14:53

Given the following code, will ixAdd do what you\'d expect, i. e. return the value of ix before the increment, but increment the class member before leaving the function?

5条回答
  •  抹茶落季
    2020-12-11 15:50

    Yes, it does.

    But don't do that, it is bad style to have side effects in expressions.

提交回复
热议问题