What does passing by value mean? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 81: What does passing by value mean?
Рекомендации по теме
Комментарии
Автор

This one is a pretty weird nomenclature for me anyway.

It's always pass by value because even with objects, what you actually pass is the value of the reference, that is, something that points to the same object.

But it doesn't look like it's exactly like what a reference is in C++ for example..

SZMarcos
Автор

In case of objects, value of reference for the object in heap is passed, so it is also pass by value. It is a bit confusing at first.

nirjharroy
Автор

The wording here is confusing. What is called a "reference" in Java is not quite the same thing as a "reference" in the context of "passing by reference".
As far as I understand it, Java references are more like C++ pointers that you can't dereference or do arithmetic on, and that only support the `->` operator (but written as `.` in Java).

jay_sensz
Автор

This one is kinda confusing, am totally lost

mwigojonathanmark
Автор

Wait, does that mean that making arguments final does nothing then?

cchutney