The curious case of Java String HashCode

Introduction

Performance of string lookup

HashSet- Internal Working

How HashSet/HashMap stores objects
HashSet/HashMap collisions as a result of non-uniform hashing

HashCode Design

HashCode of random strings in the example

Overcoming the performance penalty

Why not fix HashCode?

English Strings that hash to 0

Senior Software Engineer @Microsoft. Writes about Distributed Systems, Programming Languages & Tech Interviews

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store