i am passing an array b[] to editArray() which should return an edited array
byte[] b = {1, 2, 3, 4};
byte[] b2 = editArray(b);
for (byte t: b) System.out.print(t + ", "); System.out.println();
for (byte t: b2) System.out.print(t + ", ");
editArray();
public static byte[] editArray(byte[] bArray){
for(int i=0; i<bArray.length; i++) bArray[i] = 0;
return bArray;
}
since java is passing by values, i was expecting b[] to have no changes.
here is the output
0, 0, 0, 0,
0, 0, 0, 0,
* please can any one explain this for me, in some blogs the says : "Java passes objects as references passed by value". i cant get it.*