The result you are suppose to get is 0, but I don't understand why? The array is changed when its passed through other method.
public class Tester {
  public static int function1 (int [] arr) {
    arr= function2(arr);
    return arr[0];
  }
  public static int[] function2 (int [] arr) {
    arr = new int[4];
    return arr;
  }
    public static void main(String[] args) {
      int arr[] = {1,2,3,4};
      System.out.print(Tester.function1(arr));
    }
}
I expected 4 from the printed answer.
 
    