

- 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
Get Hash Code for Integer in Java
The HashCode for an Integer can be obtained using the hashCode() method in Java. This method does not accept any parameters and it returns a hash code value of the Integer object.
A program that demonstrates the hashCode() method in Java is given as follows:
Example
import java.lang.*; public class Demo { public static void main(String args[]) { Integer i = new Integer(60); System.out.println("The integer value is: " + i); System.out.println("The Hashcode for the above value is: " + i.hashCode()); } }
Output
The integer value is: 60 The Hashcode for the above value is: 60
Now let us understand the above program.
The Integer i is defined. Then the Integer value is printed and its HashCode is also printed using the hashCode() method. A code snippet which demonstrates this is as follows:
Integer i = new Integer(60); System.out.println("The integer value is: " + i); System.out.println("The Hashcode for the above value is: " + i.hashCode());
- Related Questions & Answers
- Format Specifier for Hash Code in Java
- Get the hash code for this instance in C#
- Obtain the hash code for a string in Java
- Get the hash code for the current Decimal instance in C#
- Get the hash code for the current Int64 instance in C#
- Hash Tables for Integer Keys in Data Structure
- How to get hash code for the specified key of a Hashtable in C#?
- MySQL get hash value for each row?
- Python Pandas - Get integer location for requested label
- Get the Machine limits information for integer types in Python
- Python Pandas IntervalIndex - Get integer location for requested label
- Java Program to check for Integer overflow
- C++ code to find index where this is a hash collision
- Different ways for Integer to String conversion in Java
- Checking for Key/Value Existence in Perl Hash
Advertisements