25.6k views
0 votes
Write the definition of a method, isReverse, whose two parameters are arrays of ints 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.)

User Wakeupneo
by
4.4k points

1 Answer

3 votes

Answer:

The following are code in the Java Programming Language.

//define boolean type function

boolean isReverse(int ar[], int b[])

{

//declare integer type variable

int x;

//set the for loop

for (x=0; x < ar.length && ar[x] == b[ar.length-1-x]; x++);

return x == ar.length;

}

Step-by-step explanation:

The following are the description of the code.

In the above code that is written in the Java Programming Language, we define the boolean data type function that is 'is Reverse()' and pass two array integer data type arguments that is 'ar', 'b' in the then, declare integer data type variable that is 'x'. Set the for loop that the boolean type value is true or false.

User Maxim T
by
5.3k points