Java 9 — Array equals, compare, mismatch method

Stuti Jain
Mar 31, 2021

--

Traditionally Arrays are everywhere.

Some of the common problems with arrays in earlier java implementations was on how to compare them.

prior to Java 8

post Java 8

problem here was if we want to test a particular sequence /subset within the array we still had to loop through it.

so Java 9 onwards we have overloaded definition

Similarly we have the compare function definitions to compare any two arrays

There is a new function in Java9 mismatch which returns the first index from where mismatch occurs/length of sequence upto which two arrays match.

--

--