search

Home  >  Q&A  >  body text

The difference between call by value and call by reference in Java

I’m a little confused about the call by value and call by reference parts in Java. I hope someone with expertise can give me some advice or recommend some good articles or blogs. Thanks.

高洛峰高洛峰2752 days ago859

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-17 10:05:50

    Call by value is easy to understand. The value of the basic data type is allocated on the stack. What is called and modified is the value on the stack.
    Call by reference. To be precise, it should be call by address reference. What is called is the address reference. , which is the address on the heap.

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-17 10:05:50

    Java is all about call by value, but when calling a function, if it is a primitive type, a copy of the original type address is passed, and if it is a reference type, a copy of the reference type address is passed.

    Ref:

    is-java-pass-by-reference-or-pass-by-value
    is-java-really-passing-objects-by-value

    reply
    0
  • Cancelreply