Question: Create a class called Task2.java. Besides the main method, you need to write a method called switchValues that accepts two integer arrays as parameters and
Create a class called Task2.java. Besides the main method, you need to write a method called switchValues that accepts two integer arrays as parameters and switches the contents of the arrays. Assume the two arrays are of same size.
In the main method, test the switchValue method. Create two int arrays and initialize them. Invoke the method switchValues and then, print out the values of the two arrays using a for loop. Their values should be changed.
As a conclusion, choose the correct answer of the following question: When passing an entire array as a parameter, _________________.
A. changing the formal parameter will affect the acutual parameter B. changing the formal parameter will not affect the acutual parameter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
