Write a method called switchThem that accepts two integer arrays as parameters and switches the contents of the arrays. Take into account that the arrays may be of different sizes.
What will be an ideal response?
```
public void switchThem(int[] first, int[] second)
{
if (first.length == second.length)
{
// copy contents of first into temp
int [] temp = new int[first.length];
for (int i = 0; I < first.length; i++)
temp[i] = first[i];
//copy contents of second into first
for (int i = 0; I < first.length; i++)
first[i] = second[i];
//copy contents of temp into second
for (int i = 0; I < first.length; i++)
second[i] = temp[i];
}
else
System.out.println("Arrays are of different sizes");
}
```
You might also like to view...
In general, if many people need copies of output, which of these is the best alternative?
A) audio B) CD ROM C) Web-based documents D) display screen
Text that you type into a Search box to locate specific files is known as search ________
Fill in the blank(s) with correct word
Forms can be placed anywhere on a Web page.
Answer the following statement true (T) or false (F)
When you delete files from a(n) ____, they do not go to the Recycle Bin.
A. USB flash drive B. hard drive C. folder D. list