Menu
Hashcode() in Java
Course Lessons
Free DSA Resources: Courses, YouTube Channels & 2026 Roadmap
A Career in Digital Marketing - A Complete Guide for Beginners
Structure of DBMS Explained: Components, Diagram & Architecture
Advanced Algorithms and Problem Solving Techniques
Data Structures: Foundation of Effective Programming
Importance of Banks: Role of Banking System in Economy, Business & Development
What Is Marketing? Definition, Types and Importance
STP Marketing Framework: Segmentation, Targeting and Positioning
What Is Branding? Meaning, Elements and Importance
What Is Digital Marketing and Why It Matters in India
Product Life Cycle: The 4 Stages Explained
Indian Brand Success Stories & Lessons
Content Marketing Strategy: A Step-by-Step Framework
Evolution of Marketing: Eras and Orientations
SEO vs SEM: Differences, Pros and Cons
GE-McKinsey Matrix: The Nine-Box Portfolio Model
Marketing Frameworks Cheat Sheet: Quick Reference
Email Marketing Best Practices That Drive Results
Influencer Marketing Strategy: A Complete Guide
The 9 Digital Marketing Channels Explained
Core Branding Concepts: Identity, Image and Equity
Marketing Mix Explained: The 4Ps and 7Ps
Sales vs Marketing: Key Differences Explained
Goods vs Services Marketing: What's the Difference?
AIDA Model: The 4 Stages of the Customer Journey
Brand Architecture Models: Branded House vs House of Brands
The Digital Marketing Funnel: Awareness to Conversion
B2B vs B2C Marketing: Differences, Examples and Strategy
BCG Matrix Explained: Stars, Cash Cows, Dogs & Question Marks
Case Study Frameworks for Analytics Interviews
Brand Extension vs Line Extension: Strategy, Fit and Risks
Digital Marketing Terms: CPC, CTR, ROAS and More
Kapferer's Brand Identity Prism: The 6 Facets
Ansoff Matrix: The 4 Growth Strategies with Examples
Customer Psychology in Marketing: Needs and Buyer Behaviour
Marketing Terms & Jargon: A Beginner Glossary
Porter's Five Forces: Industry Analysis Framework
Digital Marketing Jobs and Career Roles in India
Brand Positioning Bullseye Framework
PESTLE Analysis: Meaning, Factors and India FMCG Examples
Essential Digital Marketing Tools & Platforms for India
Co-Branding and Brand Personality Explained
What Is Brand Architecture? Types and Examples
AI and GenAI in Analytics - The Modern Analyst's Toolkit
Analytics Metrics Deep-Dive: A/B Testing and Retention
Brand Extension vs Line Extension: Meaning & Examples
Brand Differentiation: Practical Levers to Make a Brand Stand Out
Digital Marketing Frameworks for Campaign Planning
SWOT Analysis: How to Build One with Examples
Brand Equity Measurement and Brand Valuation
Keller's Brand Equity Model (CBBE Pyramid) Explained
The Marketing Environment: Micro and Macro Factors
Introduction to Big Data
Introduction to Deep Learning: From Basics to Advanced Concepts
Step-by-Step Guide to Data Visualization with Power BI
How To Start Your Career In Data Science
Data Communication: Process, Components, Types & Models for Networks
Basics of Javascript
Why is it Important for Freshers to Work in a Team?
The Multifaceted Relationships Between Banker and Customer
What are Node.js and Basics of Node.js?
Does a Linkedin profile really matter before getting a Job?
10 Common Data Structures Every Programmer Must Know
6 Bootstrap Tools and Playground – One-stop shop for all Web Developmental Needs
Introduction to Management Interview Preparation
Why Learn English?
Grooming and Etiquette: Complete Guide for Professional and Corporate Success
Getting Started with Tableau: Installation and Introduction
Discover the Versatility of Microsoft Excel: Your Swiss Army Knife for Data
What is Marketing? Core Concepts and Evolution of Marketing Eras
Header in C++
Ultimate Guide to HR Interview Questions for Freshers
JSON vs XML: Differences
Why Social Media Marketing Is Important?
Why Data Visualization is Important for Becoming a Data Scientist
Most Common 10 Telephonic Interview Questions
Fundas of Pandas
What is the Scope of Digital Marketing in 2025
A quick guide to Asymptotic Analysis
Operating System: Functions
Data Science vs. Data Analytics - What's the Difference?
Types of Data in Statistics
What are Collections in Python?
What is Search Engine Optimization & How It Works
OOPs (Object Oriented Programming) in C++
Understand Serialization and Deserialization in Java
What is Full Stack Development?
Javascript vs Typescript: What is the Difference?
Introduction to Big Data Analytics: From Basics to Implementation
Fundamentals of Digital Marketing
Introduction To SQL: A Complete Guide
Introduction to Goal Setting and Risk Profiling
How To Start Competitive Programming - A Complete Guide
How to Apply for Jobs as Fresher & Get Selected in One Go
All about C Programming Language
Learn about Boolean in Python
Software Testing: What it is?
What is Email Marketing in Digital Marketing?
Encapsulation in Java: A Comprehensive Tutorial
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 |
Social Media Marketing in India: Platform Selection Guide