Java equals() vs Arrays.equals()

0 votes

I was working with arrays, but I really got confused with the following two concepts:

array1.equals(array2);
Arrays.equals(array1, array2);

Please explain if there is any difference between the two, or both works the same.

Oct 11, 2018 in Java by anto.trigg4
• 3,420 points
36 views

1 answer to this question.

0 votes

Here,

array1.equals(array2)meansarray1 == array2

That is, it checks whether both the arrays are same or not. While, 

Arrays.equals(array1, array2)

compares the contents of both the arrays.

answered Oct 11, 2018 by code.reaper12
• 3,450 points

Related Questions In Java

0 votes
2 answers

How to concatenate two arrays in Java?

public <T> T[] concatenate(T[] a, T[] b) ...READ MORE

answered Jul 19, 2018 in Java by Sushmita
• 6,840 points
326 views
0 votes
1 answer

concat() vs “+” operator : In Java for String concatenation

Basically, there are two important differences between ...READ MORE

answered Apr 27, 2018 in Java by Rishabh
• 3,540 points
680 views
0 votes
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,540 points
42 views
0 votes
1 answer

What is the difference == and equals() in Java?

Both the answers (Syntaxes) are correct. If ...READ MORE

answered Jun 5, 2018 in Java by Akrati
• 3,150 points
26 views
0 votes
1 answer

Maximum size of an Java array

Well, you can check it by using Integer.MAX_VALUE ...READ MORE

answered Oct 31, 2018 in Java by code.reaper12
• 3,450 points
235 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,380 points

edited Nov 6, 2018 by Omkar 6,126 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,614 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
4,302 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

answered May 10, 2018 in Java by code.reaper12
• 3,450 points
100 views
0 votes
1 answer

Java Timer vs Executor Service

According to Java Concurrency in Practice: Timer is ...READ MORE

answered Jul 26, 2018 in Java by code.reaper12
• 3,450 points
535 views