subject

In this program why can arrays values stored in index be changed in both main method and mystery method, when the array is declared in main as a local variable? when the array is printed in the main method, the chnage took in the mystery method is present, why is this? is it a property of arrays?
public class referencemystery {
public static void main(string[] args) {
int x = 0;
int[] a = new int[4];
x = x + 1;
mystery(x, a);
system. out. println(x + " " + arrays. tostring(a));
x = x + 1;
mystery(x, a);
system. out. println(x + " " + arrays. tostring(a));
}
public static void mystery(int x, int[] a) {
x = x + 1;
a[x] = a[x] + 1;
system. out. println(x + " " + arrays. tostring(a));
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 13:30
What are the main arguments/points presented in the video about consciousness? present your opinion about the arguments. do you agree with all points? feel free to offer you personal reflections about the video?
Answers: 1
question
Computers and Technology, 22.06.2019 05:00
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system.in); is given.
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print.
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Jason needs to learn a new web tool. he went through his books to understand more about it. now he wants hands-on experience with using that tool. what would him? jason can use websites where workspace is provided to test the results of your code.
Answers: 2
You know the right answer?
In this program why can arrays values stored in index be changed in both main method and mystery met...
Questions
question
Mathematics, 09.06.2020 05:57
Questions on the website: 13722360