Ask Question
6 August, 08:14

Write the definition of a method, isReverse, whose two parameters are arrays of integers of equal size. The method returns true if and only if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.)

+4
Answers (1)
  1. 6 August, 11:29
    0
    public static boolean isReverse (int [ ]a, int [ ]b) {

    for (int i=0; i
    {

    if (! (a[i] = = b[a. length-i-1]))

    return false;

    }

    return true;

    }

    Explanation:

    Using a for loop, we go through the elements of the first array. The if comapres and checks if any of the values are not the same as the appropriate value on the other array, if it is so, then it is not a reverse, and we return false. else we return true.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write the definition of a method, isReverse, whose two parameters are arrays of integers of equal size. The method returns true if and only ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers