الرجوع
تسجيل الدخول

Given two methods defined in a Java program:

public static void modifyArray(int[] arr) {
    arr[0] = 10;
}

public static void modifyReference(int[] arr) {
    arr = new int[]{1, 0, 1};
}

And the following main method:

public static void main(String[] args) {
    int[] originalArray = {1, 2, 3};
    modifyArray(originalArray);
    System.out.println(originalArray[0]);  // Line 1
    modifyReference(originalArray);
    System.out.println(originalArray[0]);  // Line 2
}

What are the outputs at Line 1 and Line 2 respectively?