Ask 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 if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.)

+2
Answers (1)
  1. 8 July, 01:00
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers