Computers and Technology

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));
}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:10, 17795
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
image
Computers and Technology, 22.06.2019 16:10, katherineweightman
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
image
Computers and Technology, 23.06.2019 07:10, anika420
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
image
Computers and Technology, 23.06.2019 09:00, Riddledjam44623
Before you record your own voice, you should a. record other people's voices b. warm up and practice difficult names c. listen to your favorite songs d. read a transcript of a good radio news segment
Answers: 1
Do you know the correct answer?
In this program why can arrays values stored in index be changed in both main method and mystery met...

Questions in other subjects:

Konu
Mathematics, 09.04.2021 21:40