pass by value in java (primitive and arrays) -


suppose have following code:

public static void main(string[] args) {     int x = 5;     int [] array = new int[10];     swtich (x, array);     system.out.println("x = " + x);     system.out.println("y[0] = " + y[0]); }  public static void switch(int number , int[] array){     number = 10;     array[0] = 150; } 

why program prints 5 (doesn't change value) , prints number ordered in array[0] 150?

thanks.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -