java - is it possible to change the original variable when it is passed as an argument to the function -


this question has answer here:

am trying change value of variable when passed argument function, original value remains same, possible change?(i,e in below code want value of x 11)

public  class runy  {  public static void main(string [] args)  {       int x=10;     int y=change(x);      system.out.println(x);     system.out.println(y);  } public static int change(int a) {     a+=1;     return a; } 

}

i,e in below code want value of x 11)

with current code, won't possible if want change value of x, don't need y , can

 int x=10;  x=change(x); // store return value of change 'x' 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -