Immutable and pass by value

前端 未结 4 1975
我在风中等你
我在风中等你 2020-12-29 14:01

I have the following code which has
a mutable Person class, String and a method to modify the instances of String and Person

    class Person{

int a = 8         


        
4条回答
  •  没有蜡笔的小新
    2020-12-29 14:35

    Sometimes people get confused when passing by reference. It's possible to change the object that the reference refers to (giving the impression of pass-by-reference), but it is not possible to modify reference itself. So it still remains pass-by-value.

提交回复
热议问题