Passing an int and an array to a method
Predict the outputEasy-MediumJava onlyAsked in: Arista Networks
public class Main {
static void change(int x) {
x = 10;
}
static void change(int[] arr) {
arr[0] = 10;
}
public static void main(String[] args) {
int n = 5;
int[] arr = {5};
change(n);
change(arr);
System.out.println(n + " " + arr[0]);
}
}
Graded by exact match. Spaces at the ends of lines and blank lines at the end do not count.
to answer and keep your progress. Reading is free for everyone.