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...
When you delete a record in a table, it ________ display in any other objects that are created using the table
A) will B) will no longer C) leads the D) will initially
An underlying, but invisible, set of horizontal and vertical lines of a document is known as a(n) ________
Fill in the blank(s) with correct word
The terms class method and class ____________________ are used interchangeably in C++.
What will be an ideal response?
Which of the following variable names is valid?
A. Total Score B. TotalScore C. 123Count D. Score#