I'm not sure of what your question is. You pass the array to a method, increment one of the elements, and then print off that elelment back in main. This is all perfectly legal and valid. By the way, you have a typo in your code, you have muValue instead of myValue. Bill
Hi, Arrays are objects, meaning that programs deal with references to arrays, not with arrays themselves. What gets passed into a method is a copy of reference to an array. It is therefore possible for a called method to modify the caller's array. At line 4 you are calling a method which increments the value from 1 to 2 hence on line 5 you are getting output as 2.
This because array is a object. You are passing a reference to the Array object and then modifying its value. Had it just been an int and not an array of int, then you would see the results you are looking for. That is not change in value.