Compare two sets of arrays

I want to compare 2 sets of array of 16 items to determine if the items are identical both in position and values.

arr1 (1,2,3,4,4,6,7,8,9,10,11,12,13,14,15,16)
arr2 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)

arr1 (2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
arr2 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)

arr1 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
arr2 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)

How can I achieve this?

if arr1(1:16) = arr2(1:16)
Print ‘same’
Print ‘not same’

Do not use “(*)” on both sides.

Kind regards

You can redefine both arrays and compare the redefined fields

Hi, you can use the equals() method of java.util.Arrays.

If you are concerned with performance, redefine the two arrays as follows (I am simply assuming the arrays are alpha and five positions long).

1 arr1 (a5,1:16) would become #all1 (a80)

A similar change would be made for arr2 and #all2.

Now you check to see if #all1 = #all2.

One comparison as opposed to sixteen.

If this is done a few million times a day, you might not have to increase the power of your computer.

Steve Robinson
(still concerned about performance)


This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.