
Patrick B. answered 05/08/21
Math and computer tutor/teacher
Array is an object in and of itself and is passed by reference.
The subroutine changes the caller's copy
Artem H.
asked 05/07/21Here is a program that tries to change the value of one the element of an array by passing the array to a changeNames method:
Is This True?
The output of this program is
[Alison, Biance, Cody, Derek]
class Main {
public static void main(String[] args) {
String [] names = {"Amy", "Biance", "Cody", "Derek"};
String [] change= changeNames(names);
System.out.println(Arrays.toString(change));
}
public static String [] changeNames(String [] names){
String [] change = names;
names[0]= "Alison";
return change;
}
}
Patrick B. answered 05/08/21
Math and computer tutor/teacher
Array is an object in and of itself and is passed by reference.
The subroutine changes the caller's copy
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.