
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the method equals(int[] a1, int[] a2) do in java?
The equals(int[] a, int[] a2) method of java.util.Arrays returns true if the two specified arrays of integers are equal to one another. Two arrays are equal if they contain the same elements in the same order. Two array references are considered equal if both are null.
Example
import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { int[] arr1 = new int[] { 10, 12, 5, 6 }; int[] arr2 = new int[] { 10, 12, 5, 6 }; int[] arr3 = new int[] { 10, 5, 6, 12 }; boolean retval = Arrays.equals(arr1, arr2); System.out.println("arr1 and arr2 equal: " + retval); boolean retval2 = Arrays.equals(arr2, arr3); System.out.println("arr2 and arr3 equal: " + retval2); } }
Output
arr1 and arr2 equal: true arr2 and arr3 equal: false
- Related Questions & Answers
- What does the method equals(obj[] a1, obj[] a2) do in java?
- What does the method fill(int[], int fromIndex, int toIndex, int val) do in java?
- What does the method fill(int[], int val) do in java?
- What does the method sort(int[] a, int fromIndex, int toIndex) do in java?
- What does the method copyOfRange(int[] original, int from, int to) do in java?
- What does the method removeRange(int fromIndex, int toIndex) do in java?
- What does the method copyOf(int[] original, int newLength) do in java?
- What does the method fill(obj[], int fromIndex, int toIndex, int val) do in java?
- What does the method int capacity() do in java?
- What does the method get(int) do in java?
- What does the method remove(int) do in java?
- What does the method sort(obj[] a, int fromIndex, int toIndex) do in java?
- What does the method ensureCapacity(int, minCapacity) do in java?
- What does the method hashCode(int[] a) do in java?
- What does the method sort(int[] a) do in java?
Advertisements