0

In java , let's say I have a reference to an object , and a function:

object p = new object();
function(p);

where function is:

public void function(object x)
{
///
}

What actually happens in memory here?I think of x and p as pointers in C++.Will "x" and "p" have the same value,but different adresses in memory , or they will have the same value and adress?Thanks.

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • java is "passed by value of the reference". once you understand that, things are easy. and this is a duplicate anyway – Eugene Apr 21 '21 at 14:54
  • Does [Is Java pass by reference or pass by value](https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value) answer your question? – Wouter van der Linde Apr 21 '21 at 14:55

0 Answers0