- Explore [has_child]
- All Courses [subitem]
- AI Career Platform [subitem]
- Hire form us [subitem]
- 1:1 Coaching/Mentoring [subitem]
- Job Board [subitem]
- Institute Partnerships [subitem]
- Resources [has_child]
- Master Classes [subitem]
- Discussion Forum [subitem]
- Coding Playground [subitem]
- Free Courses [subitem]
- Topics [has_child]
- Data Science [subitem]
- Software Development [subitem]
- Company Insights
- Interview Preparation [subitem]
- Python [subitem]
- Programming [subitem]
- Digital Marketing [subitem]
- Web Development [subitem]
- Success Stories [subitem]
Data Structures: Foundation of Effective Programming
Fundamentals of LCM and HCF-2
A Career in Digital Marketing - A Complete Guide for Beginners
Advanced Algorithms and Problem Solving Techniques
Why Learn English?
Basic Guide to HTML & CSS – The Fundamentals of Web Development
Introduction to Deep Learning: From Basics to Advanced Concepts
Basics of Javascript
The skills required to stay relevant in IT sector
Why is it Important for Freshers to Work in a Team?
The Role and Importance of Banks in the Economy
Introduction to Big Data
What Is Content Marketing?
Python Libraries
Introduction To Cloud Computing
10 Common Data Structures Every Programmer Must Know
What is the Scope of Digital Marketing in 2025
6 Bootstrap Tools and Playground – One-stop shop for all Web Developmental Needs
How To Start Competitive Programming - A Complete Guide
A quick guide to Asymptotic Analysis
What are Node.js and Basics of Node.js?
Mastering Vocabulary: The Key to Verbal Ability
Fundamentals of Divisibility Rules in Quantitative Aptitude
A-Z about Python Variables
What are Collections in Python?
Javascript vs Typescript: What is the Difference?
Learn about Boolean in Python
Understand Serialization and Deserialization in Java
OOPs (Object Oriented Programming) in C++
Header in C++
C++ Language: An Overview
Secrets Of A Good Resume, Which Will Get You Hired!
Structure of DBMS
What is Email Marketing in Digital Marketing?
What is Search Engine Optimization & How It Works
Operating System: Functions
How to Apply for Jobs as Fresher & Get Selected in One Go
How To Start Your Career In Data Science
All About Resume and Its Importance
Data Science vs. Data Analytics - What's the Difference?
The Ultimate Guide to Resume building for Freshers
What is a Job Interview?
Ultimate Guide to HR Interview Questions for Freshers
The Multifaceted Relationships Between Banker and Customer
Encapsulation in Java: A Comprehensive Tutorial
Software Testing: What it is?
What is Full Stack Development?
Job Trends In This Decade
Why Social Media Marketing Is Important?
Does a Linkedin profile really matter before getting a Job?
Why Group Discussion for Interview? The HR Perspective
Software: Types & Definition
What is Consulting? Essential Insights for Aspiring Consultants
Fundamentals of Digital Marketing
Introduction To SQL: A Complete Guide
Discover the Versatility of Microsoft Excel: Your Swiss Army Knife for Data
Introduction to Goal Setting and Risk Profiling
React Functional Components: Introduction
Introduction to Natural Language Processing (NLP)
Fundas of Pandas
Data Communication: A Process
What is Digital Marketing & How to Become a Digital Marketer
What is Meant by Machine Learning & What Can Machine Learning Do?
Why Data Visualization is Important for Becoming a Data Scientist
All about C Programming Language
Types of Data in Statistics
Introduction to Big Data Analytics: From Basics to Implementation
JSON vs XML: Differences
What is Grooming & Etiquette?
Java Programs: Know the Best Java Programs for Beginners
Most Common 10 Telephonic Interview Questions
Step-by-Step Guide to Data Visualization with Power BI
Introduction to Management Interview Preparation
Getting Started with Tableau: Installation and Introduction
Mastering SWOT Analysis for Business Success
The Essential SUM Function in Excel: A Step-by-Step Guide
Master Simple and Compound Interest Quickly and Accurately
Creating and Using Sets in Tableau: A Comprehensive Guide
Understanding the Loan Underwriting Process
System Testing: Explained
Understanding the Difference in Simple and Compound Interest over 2 and 3 Years
Understanding Risk and Return in Mutual Funds
Mastering Value Chain Analysis: Uncovering Business Opportunities
Mastering the MIN Function in Excel: Find the Lowest Value Instantly
Mastering Data Filters in Tableau: A Step-by-Step Guide
Creating Calculated Fields in Tableau: A Step-by-Step Guide
Understanding Principle Multiplication with Compound and Simple Interest
Understanding Credit Scoring Models: A Comprehensive Insight
Understanding PESTEL Analysis for Industry Evaluation
Combining Data Sources Using Data Blending in Tableau
Understanding Simple Interest vs. Compound Interest
Mastering Mutual Fund Investment and Redemption Plans
Mastering the COUNT Function in Excel
Mastering the GE-McKinsey 9-Box Matrix: A Strategic Guide
Understanding Credit Rating Agencies and Their Processes
Mastering the COUNTA Function in Excel
Bringing in More Data with Joins in Tableau
Mastering Mixtures and Alligations: Key Techniques and Practice
Maximizing Organizational Performance with the Balanced Scorecard
The Role of Financial Planning in Wealth Creation
Introduction
In computer science, hashing is a concept that involves mapping entities or objects to integer values. The values of those entities are called hashcodes or hash values.
In Java, to compute hash values of objects, the hashCode() method is used. In Java, the Integer class has two methods:
- hashCode(): It computes the hash values of the Integer.
- hashCode(int value): It computes the hash values of primitive int values.
Properties of Hashing
- When the output of the equals() method is the same as the object then they have the same hash value. That means they need to be mapped to the same Integer value.
- When two objects are not equal, they may or may not have the same hash values. That is why different objects do not need to have different hash values.
- When hash values of objects are computed multiple times, their hash values should remain consistent.
- When invoked more than once during the execution, the output of hashing algorithm must be the same for the same objects.
- But, from one execution to another execution the value does not need to stay consistent.
Java hashCode() Method
To compute the hash values of input objects, there is the hashCode() method in java. The value of that integer which represents the input object’s hash value, that integer is returned.
To produce the hash values of objects, the hashCode() method is used. These objects are then stored in Java collections such as HashMap, HashSet and HashTable by using these hash values.
In this example, we will see the properties of hashing by testing the following things:
Two objects having the same values also have the same hashcodes.
Objects that do not have the same values also don’t have the same hashcodes.
When the hashcodes of the same object are computed again, it gives the same hashcode or the hashcode is consistent.
Code
import java.io.*; |
Output:
HashCode of a1 = 100 is: 48625 |
Integer class hashCode(int value) Method
As can be seen clearly, this method computes the hash value of its parameter and return its hashcode.
Code
// Example of hashCode(int value) |
Output:
HashCode of value = 144 is : 144 |