Java method doesn't change parameter objects -


this question has answer here:

i have function this:

public static int partition(list list, listelement eleml, listelement elemr){     listelement elemx;     ...     elemr = elemx.next;     return x;  } 

and @ end of funktion elemr changed, after calling function main method parameter elemr has still same value before function call. what's problem? how can change listelement , "save" change after function called without changing return type listelement (i need integer return value too)?

java functions parameters called reference name, meaning when place object function argument, jvm copies reference's value new variable, , passes function argument. if change contents of object, original object change, if change actual value of reference, these changes destroyed when function ends.

i hope helps


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -