The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to compare two arrays in Java - String, Integer Array Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to compare two arrays in Java - String, Integer Array Example Posted: May 29, 2014 7:25 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to compare two arrays in Java - String, Integer Array Example
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
Our task is to compare two arrays in Java and see if they are equal to each other or not. Of-course we can't compare an String array to an int array, which means two arrays are said to be equal if they are of same type, has same length, contains same elements and in same order. Now, you can write your own method for checking array equality or take advantage of Java's rich Collection API. Similar to what we have seen while printing array values in Java, java.util.Arrays class provides convenient methods for comparing array values. They take care of all four condition, I have mentioned above. In fact, Arrays class also provide deepEquals() method to compare two dimensional array in Java. By the way it's not restricted to just two dimensional and also valid for any multi-dimensional array. In this article, we will see examples of comparing two String array, two Integer array and two multi dimensional array to learn how to use equals() and deepEquals() methods of java.util.Arrays class. Also difference between equals() and deepEquals() is a good Java interview question, and asked into of couple of fresher and mid level interviews.
Read more ยป

Read: How to compare two arrays in Java - String, Integer Array Example

Topic: API design and performance Previous Topic   Next Topic Topic: java.lang.ClassCastException โ€“ How to solve Class Cast Exception

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use