1.

How to check the equality of two arrays?

Answer»

You will be given two arrays and you have to check whether the 2 arrays are equal or not.

First, you have to check the lengths of two given arrays. When the length of both arrays is the same, we COMPARE corresponding elements of both arrays. Both the arrays will be considered equal If all corresponding pairs of elements are equal. If the arrays are big in size this method will be time-consuming therefore this method is not recommended to check the equality of two arrays. You can ALSO use the in-built equals() method of Arrays class but in the interview, the INTERVIEWER may ask you to compare two arrays without using in-built FUNCTIONS therefore this method will HELP you at that time.



Discussion

No Comment Found