Ask Question
13 November, 23:11

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.)

+5
Answers (1)
  1. 14 November, 01:51
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers