- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 hashCode(int[] a) do in java?
The hashCode(int[]) method of the java.util.Arrays class returns a hash code based on the contents of the specified array. For any two non-null int arrays a and b such that Arrays.equals(a, b), it is also the case that Arrays.hashCode(a) == Arrays.hashCode(b).
Example
import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { int[] ival = new int[] { 3, 5 }; int retval = ival.hashCode(); System.out.println("The hash code of value1 is: " + retval); ival = new int[] { 19, 75 }; retval = ival.hashCode(); System.out.println("The hash code of value2 is: " + retval); } }
Output
The hash code of value1 is: 4072869 The hash code of value2 is: 1671711
Advertisements