arrow_back Back to Notebook
java
java
January 10, 2019

Compare arrays with Java

There are many such use cases where you will find yourself required to compare two arrays in Java.

Remembering a few of the different ways to do so is a tool which should be in any programmers toolbox.

Compare using Java 8

IntStream.range(0, arr.length)
    .forEach((i) -> arr[i] == b.get(i))

Compare using Java 5+

return Arrays.deepEquals(arr1, arr2);

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch