How to implement int in/out params in java

前端 未结 6 2090

Apologies for asking such a primitive question.

I wrote a function which took one parameter; this parameter was supposed to be an in/out parameter.

After d

6条回答
  •  眼角桃花
    2020-12-21 12:29

    Question 2. Calling currentFoo = currentFoo + 1 when working with results in a new object being created and its reference stored in currentFoo. The compiler doesn't complain because it's not invalid Java - it just results in a new object being created, rather than the current one being updated.

提交回复
热议问题