returning a value from a method to another method

前端 未结 8 585
时光取名叫无心
时光取名叫无心 2021-01-19 14:42

Can somebody tell me why the value returned is 3 and not 8. Doesn\'t the return x statement from the addFive method change the value of x

8条回答
  •  终归单人心
    2021-01-19 14:47

    Because you're simply not using the computation of your function. It doesn't change value of x, it returns new value.

    You should do something like:

    int y = addFive(x);
    

提交回复
热议问题